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

Re: git-fetch question/bug

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 14, 2008, 05:27 UTC
Message-ID
<7vbq5hub74.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<5d46db230803132208r3f3f9e34q80bb9c03d65ab67c@mail.gmail.com>
"Govind Salinas" <blix@sophiasuchtig.com> writes:
> ... git-fetch when I discovered that it does not return
> error when the
> fetch fails due to it not being a ff...

I think this is a regression introduced when "git-fetch" was re-implemented in C. git-fetch--tool's native-store subcommand seems to have signaled this as an error, and it is reasonable to expect an error exit from the command in this case.

Probably something like this?
 builtin-fetch.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 55f611e..a2deb3e 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -297,7 +297,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
 {
 	FILE *fp;
 	struct commit *commit;
-	int url_len, i, note_len, shown_url = 0;
+	int url_len, i, note_len, shown_url = 0, err = 0;
 	char note[1024];
 	const char *what, *kind;
 	struct ref *rm;
@@ -364,7 +364,8 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
 			note);
 
 		if (ref) {
-			update_local_ref(ref, what, verbose, note);
+			if (update_local_ref(ref, what, verbose, note))
+				err = 1;
 			if (*note) {
 				if (!shown_url) {
 					fprintf(stderr, "From %.*s\n",
@@ -376,7 +377,7 @@ static int store_updated_refs(const char *url, struct ref *ref_map)
 		}
 	}
 	fclose(fp);
-	return 0;
+	return err;
 }
 
 /*
Previous: Govind SalinasNext: Jakub Narebski
Message 2 of 4 in “git-fetch question/bug”
  1. Govind SalinasMar 14, 2008
  2. Junio C HamanoMar 14, 2008
  3. Jakub NarebskiMar 14, 2008
  4. Daniel BarkalowMar 14, 2008

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.