Skip to content

Commit f475e08

Browse files
peffgitster
authored andcommitted
lock_ref: inform callers of unavailable ref
One of the ways that locking might fail is that there is a DF conflict between two refs (e.g., you want to lock "foo/bar" but "foo" already exists). In this case, we return an error, but there is no way for the caller to know the specific problem. This patch sets errno to ENOTDIR, which is the most sensible code. It's what we would see if the refs were stored purely in the filesystem (but these days we must check the namespace manually due to packed refs). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f5d4c4d commit f475e08

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

refs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,10 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
893893
* name is a proper prefix of our refname.
894894
*/
895895
if (missing &&
896-
!is_refname_available(ref, NULL, get_packed_refs(), 0))
896+
!is_refname_available(ref, NULL, get_packed_refs(), 0)) {
897+
last_errno = ENOTDIR;
897898
goto error_return;
899+
}
898900

899901
lock->lk = xcalloc(1, sizeof(struct lock_file));
900902

0 commit comments

Comments
 (0)