diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2015-05-23 01:34:54 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-05-27 12:40:29 -0700 |
commit | f41d6329704a8c3f7286f52c3589d381ac0bc79d (patch) | |
tree | ab8770db2bdc1bddd6549f97f5c7da7ee925ab4f | |
parent | verify_lock(): return 0/-1 rather than struct ref_lock * (diff) | |
download | tgif-f41d6329704a8c3f7286f52c3589d381ac0bc79d.tar.xz |
verify_lock(): on errors, let the caller unlock the lock
The caller already knows how to do it, so always do it in the same
place.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | refs.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -2232,14 +2232,12 @@ static int verify_lock(struct ref_lock *lock, lock->old_sha1, NULL)) { int save_errno = errno; error("Can't verify ref %s", lock->ref_name); - unlock_ref(lock); errno = save_errno; return -1; } if (hashcmp(lock->old_sha1, old_sha1)) { error("Ref %s is at %s but expected %s", lock->ref_name, sha1_to_hex(lock->old_sha1), sha1_to_hex(old_sha1)); - unlock_ref(lock); errno = EBUSY; return -1; } @@ -2471,8 +2469,10 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname, goto error_return; } } - if (old_sha1 && verify_lock(lock, old_sha1, mustexist)) - return NULL; + if (old_sha1 && verify_lock(lock, old_sha1, mustexist)) { + last_errno = errno; + goto error_return; + } return lock; error_return: |