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

[PATCH 2/2] fetch: report ref storage DF errors more accurately

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

When we fail to store a fetched ref, we recommend that the user try running "git prune" to remove up any old refs that have been deleted by the remote, which would clear up any DF conflicts. However, ref storage might fail for other reasons (e.g., permissions problems) in which case the advice is useless and misleading.

This patch detects when there is an actual DF situation and only issues the advice when one is found.

Signed-off-by: Jeff King <peff@peff.net>
---
This is a followup to Ingo's bug report here:
  http://thread.gmane.org/gmane.comp.version-control.git/117751
 builtin-fetch.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 77acabf..1eec64e 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -167,6 +167,9 @@ static struct ref *get_ref_map(struct transport *transport,
 	return ref_map;
 }
 
+#define STORE_REF_ERROR_OTHER 1
+#define STORE_REF_ERROR_DF_CONFLICT 2
+
 static int s_update_ref(const char *action,
 			struct ref *ref,
 			int check_old)
@@ -181,9 +184,11 @@ static int s_update_ref(const char *action,
 	lock = lock_any_ref_for_update(ref->name,
 				       check_old ? ref->old_sha1 : NULL, 0);
 	if (!lock)
-		return 2;
+		return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
+					  STORE_REF_ERROR_OTHER;
 	if (write_ref_sha1(lock, ref->new_sha1, msg) < 0)
-		return 2;
+		return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
+					  STORE_REF_ERROR_OTHER;
 	return 0;
 }
 
@@ -386,7 +391,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 	}
 	free(url);
 	fclose(fp);
-	if (rc & 2)
+	if (rc & STORE_REF_ERROR_DF_CONFLICT)
 		error("some local refs could not be updated; try running\n"
 		      " 'git remote prune %s' to remove any old, conflicting "
 		      "branches", remote_name);
-- 
1.6.3.1.250.g01b8b.dirty
Previous: Jeff KingNext: Junio C Hamano
Message 7 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.