Skip to content

Commit

Permalink
lock_ref: inform callers of unavailable ref
Browse files Browse the repository at this point in the history
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed May 25, 2009
1 parent f5d4c4d commit f475e08
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,10 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
* name is a proper prefix of our refname.
*/
if (missing &&
!is_refname_available(ref, NULL, get_packed_refs(), 0))
!is_refname_available(ref, NULL, get_packed_refs(), 0)) {
last_errno = ENOTDIR;
goto error_return;
}

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

Expand Down

0 comments on commit f475e08

Please sign in to comment.