summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2009-05-25 10:37:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-05-25 19:06:54 (GMT)
commitf475e08edbbabe38bd758fd42f08f646551468d9 (patch)
tree0e28a879e1435283fe35d12857e04b3c94b09f33 /refs.c
parentf5d4c4d0f19084a2d48f55f2f42cac25696a34f5 (diff)
downloadgit-f475e08edbbabe38bd758fd42f08f646551468d9.zip
git-f475e08edbbabe38bd758fd42f08f646551468d9.tar.gz
git-f475e08edbbabe38bd758fd42f08f646551468d9.tar.bz2
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/refs.c b/refs.c
index e65a3b4..8679c17 100644
--- a/refs.c
+++ b/refs.c
@@ -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));