lock_ref_for_update(): avoid a symref resolution
If we're overwriting a symref with a SHA-1, we need to resolve the value of the symref (1) to check against update->old_sha1 and (2) to write to its reflog. However, we've already read the symref itself and know its referent. So there is no need to read the symref's value through the symref; we can read the referent directly. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Jun 7, 2016 at 09:32 UTC
841caad903f2b160e9f5ff05f961d20ad9085ddc
1 file changed
+1
-1
refs/files-backend.c
+1
-1
@@ -3479,7 +3479,7 @@ static int lock_ref_for_update(struct ref_update *update,
3479
* the transaction, so we have to read it here
3480
* to record and possibly check old_sha1:
3481
*/
3482
- if (read_ref_full(update->refname, 0,
3482
+ if (read_ref_full(referent.buf, 0,
3483
lock->old_oid.hash, NULL)) {
3484
if (update->flags & REF_HAVE_OLD) {
3485
strbuf_addf(err, "cannot lock ref '%s': "