Re: git pull fails to exit with non-zero status after fatal error

Subsystems: the rest

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: git pull fails to exit with non-zero status after fatal error

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:58

Johannes Schindelin [off-list ref] writes:
quoted hunk
On Sat, 3 Mar 2007, Larry Streepy wrote:
quoted
$ git pull
Updating b5d9263..506b347
tools/Pvt/Pvt.py: needs update
fatal: Entry 'tools/Pvt/Pvt.py' not uptodate. Cannot merge.
$ echo $?
0

Notice the exit status of 0.
Does this fix it?
diff --git a/git-merge.sh b/git-merge.sh
index 498c938..6b23bf5 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -295,8 +295,9 @@ f,*)
 	new_head=$(git-rev-parse --verify "$1^0") &&
 	git-read-tree -v -m -u --exclude-per-directory=.gitignore $head "$new_head" &&
 	finish "$new_head" "Fast forward"
+	ret=$?
 	dropsave
-	exit 0
+	exit $ret
 	;;
 ?,1,?*"$LF"?*,*)
 	# We are not doing octopus and not fast forward.  Need a
The cation "dropsave" takes is to remove the files that are not
needed after a successful merge, so I think it is better to fail
if the && chain that ends with finish, like this.
diff --git a/git-merge.sh b/git-merge.sh
index 498c938..4afcd95 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -294,7 +294,7 @@ f,*)
 	git-update-index --refresh 2>/dev/null
 	new_head=$(git-rev-parse --verify "$1^0") &&
 	git-read-tree -v -m -u --exclude-per-directory=.gitignore $head "$new_head" &&
-	finish "$new_head" "Fast forward"
+	finish "$new_head" "Fast forward" || exit
 	dropsave
 	exit 0
 	;;

Re: git pull fails to exit with non-zero status after fatal error

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:42:58

Hi,

On Sat, 3 Mar 2007, Junio C Hamano wrote:
-	finish "$new_head" "Fast forward"
+	finish "$new_head" "Fast forward" || exit
Doesn't "exit" default to "exit 0"?

Ciao,
Dscho

Re: git pull fails to exit with non-zero status after fatal error

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:42:58

Johannes Schindelin [off-list ref] wrote:
On Sat, 3 Mar 2007, Junio C Hamano wrote:
quoted
-	finish "$new_head" "Fast forward"
+	finish "$new_head" "Fast forward" || exit
Doesn't "exit" default to "exit 0"?
No, it carries the exit status of the prior failed command if the
prior command failed.  ;-)

For what its worth, I learned that only while hacking on git-merge.
I think it is highly non-obvious.

-- 
Shawn.

Re: git pull fails to exit with non-zero status after fatal error

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:42:58

Hi,

On Sat, 3 Mar 2007, Shawn O. Pearce wrote:
Johannes Schindelin [off-list ref] wrote:
quoted
On Sat, 3 Mar 2007, Junio C Hamano wrote:
quoted
-	finish "$new_head" "Fast forward"
+	finish "$new_head" "Fast forward" || exit
Doesn't "exit" default to "exit 0"?
No, it carries the exit status of the prior failed command if the
prior command failed.  ;-)
You live and learn, live and learn...

Thanks,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help