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

[RFC] exit code from git fetch

From
Junio C Hamano <junkio@cox.net>
Date
Mar 17, 2006, 06:01 UTC
Message-ID
<7vek116253.fsf@assigned-by-dhcp.cox.net>

When "git fetch" fails because the remote unexpectedly rewound its head and fast-forward check triggers, we issued a warning but kept going anyway. This proposed patch makes the command exit with non-zero status.

I think this is a sensible change and makes it easier to use from scripts, but it might have other issues. For example when you are tracking more than one heads from the remote, and the first one fast-forwards but the second one doesn't, it updates the first one and then stops. If we happen to process the rewound one first, neither is updated because we stop at the first one. I think this particular discrepancy probably is not worth worrying about, but there may be other more serious fallouts we need to fix if we did this.

Comments?
---
diff --git a/git-fetch.sh b/git-fetch.sh
index 0346d4a..6835634 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -179,6 +179,7 @@ fast_forward_local () {
 			;;
 		*)
 			echo >&2 "  not updating."
+			exit 1
 			;;
 		esac
 	    }
Next: Andrew Morton
Message 1 of 2 in “[RFC] exit code from git fetch”
  1. Junio C HamanoMar 17, 2006
  2. Andrew MortonMar 17, 2006

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.