Skip to content

Commit f41d632

Browse files
mhaggergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5e2499 commit f41d632

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

refs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,14 +2232,12 @@ static int verify_lock(struct ref_lock *lock,
22322232
lock->old_sha1, NULL)) {
22332233
int save_errno = errno;
22342234
error("Can't verify ref %s", lock->ref_name);
2235-
unlock_ref(lock);
22362235
errno = save_errno;
22372236
return -1;
22382237
}
22392238
if (hashcmp(lock->old_sha1, old_sha1)) {
22402239
error("Ref %s is at %s but expected %s", lock->ref_name,
22412240
sha1_to_hex(lock->old_sha1), sha1_to_hex(old_sha1));
2242-
unlock_ref(lock);
22432241
errno = EBUSY;
22442242
return -1;
22452243
}
@@ -2471,8 +2469,10 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
24712469
goto error_return;
24722470
}
24732471
}
2474-
if (old_sha1 && verify_lock(lock, old_sha1, mustexist))
2475-
return NULL;
2472+
if (old_sha1 && verify_lock(lock, old_sha1, mustexist)) {
2473+
last_errno = errno;
2474+
goto error_return;
2475+
}
24762476
return lock;
24772477

24782478
error_return:

0 commit comments

Comments
 (0)