git pull fails to exit with non-zero status after fatal error
We have just upgraded to 1.5 (don't know if this is specific to 1.5, but just in case). When I perform a git-pull on a working repo that has a modified file, git pull refuses to do the pull, as shown below:
$ 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. The driver scripts I use rely on a non-zero status to send me email when the git-pull fails, but this case eludes detection.
I'm assuming this is a bug, but if it's intended behavior I'd like to understand why it would use a 0 exit status after a issuing a fatal error.
Thanks,
Larry.
Hi,
Quoted 4 lines · Larry Streepy
We have just upgraded to 1.5 (don't know if this is specific to 1.5, but just in case). When I perform a git-pull on a working repo that has a modified file, git pull refuses to do the pull, as shown below:
Quoted 8 lines
$ git pull Updating b5d9263..506b347 tools/Pvt/Pvt.py: needs update fatal: Entry 'tools/Pvt/Pvt.py' not uptodate. Cannot merge. $ echo $? 0Notice the exit status of 0.
Does this fix it?
git-merge.sh +2 -1
@@ -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
I'll give it a try and let you know.
Thanks for the quick feedback.
Larry.
Quoted 18 lines · Johannes Schindelin
Does this fix it?
git-merge.sh +2
-1@@ -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
Quoted 18 lines · Johannes Schindelin
Quoted 8 lines · Larry Streepy
$ git pull Updating b5d9263..506b347 tools/Pvt/Pvt.py: needs update fatal: Entry 'tools/Pvt/Pvt.py' not uptodate. Cannot merge. $ echo $? 0Notice the exit status of 0.
Does this fix it?
git-merge.sh +0
-0
git-merge.sh f,*) · line 303
Quoted 10 lines
git-merge.sh +2
-1@@ -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.
git-merge.sh +1 -1
@@ -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 ;;
Hi,
git-merge.sh f,*) · line 297
Quoted 2 lines · Junio C Hamano
git-merge.sh +1
-1- finish "$new_head" "Fast forward" + finish "$new_head" "Fast forward" || exit
Doesn't "exit" default to "exit 0"?
Ciao,
Dscho
Quoted 6 lines · Johannes Schindelin
git-merge.sh f,*) · line 297
Quoted 2 lines · Junio C Hamano
git-merge.sh +1
-1- finish "$new_head" "Fast forward" + finish "$new_head" "Fast forward" || exitDoesn'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.
Signature · 1 line
Shawn.
Quoted 8 lines · Shawn O. Pearce
Quoted 6 lines · Johannes Schindelin
git-merge.sh f,*) · line 297
Quoted 2 lines · Junio C Hamano
git-merge.sh +1
-1- finish "$new_head" "Fast forward" + finish "$new_head" "Fast forward" || exitDoesn't "exit" default to "exit 0"?
Quoted 5 lines
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.
Sorry to be a traditionalist. "sequence && of && commands || exit" is an established bourne shell idiom.
I do not mind if somebody proposed to change that to "... || exit $?" to unconfuse uninitiated, though.
Hi,
Quoted 10 lines · Shawn O. Pearce
Quoted 6 lines · Johannes Schindelin
git-merge.sh f,*) · line 297
Quoted 2 lines · Junio C Hamano
git-merge.sh +1
-1- finish "$new_head" "Fast forward" + finish "$new_head" "Fast forward" || exitDoesn'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