git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] lock_ref: inform callers of unavailable ref

From
Jeff King <peff@peff.net>
Date
May 25, 2009, 10:37 UTC
Message-ID
<20090525103715.GA26574@coredump.intra.peff.net>
In-Reply-To
<20090429080650.GA25227@coredump.intra.peff.net>

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>
---
We introduce a caller who cares in the next patch.
 refs.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/refs.c b/refs.c
index 45ad556..24438c6 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));
 
-- 
1.6.3.1.250.g01b8b.dirty
Previous: Jeff KingNext: Jeff King
Message 6 of 8 in “error: Unable to append to .git/logs/refs/remotes/origin/master: Permission denied”
  1. Ingo MolnarApr 28, 2009
  2. Jeff KingApr 29, 2009
  3. Jeff KingApr 29, 2009
  4. Ingo MolnarApr 29, 2009
  5. Jeff KingApr 29, 2009
  6. 1/2 lock_ref: inform callers of unavailable refJeff King, May 25, 2009
  7. 2/2 fetch: report ref storage DF errors more accuratelyJeff King, May 25, 2009
  8. Junio C HamanoMay 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.