threads / rfc / 3657

[RFC] exit code from git fetch

Subject: [RFC] exit code from git fetch

## tl;dr

2 messages between Mar 17, 2006 and Mar 17, 2006.

replies: 1people: 2as markdown or json

Junio C Hamano· Mar 17, 2006, 06:01 UTC · lore

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
 	    }
Andrew Morton· Mar 17, 2006, 06:23 UTC · re: Junio C Hamano · lore

Re: [RFC] exit code from git fetch

Junio C Hamano <junkio@cox.net> wrote:
Show 31 quoted lines
>
> 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
>  	    }
Thanks ;)

I guess you could exit with different exit codes according to what went wrong. So if a script writer really cared about the fine details, appropriate decisions could be made.

← back to recent threads