summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-08-19 15:34:15 -0700
committerJunio C Hamano <gitster@pobox.com>2016-08-19 15:34:15 -0700
commit331f06d6f1cc0e164c4aa320c2659d99de67f2f6 (patch)
tree11d0d72bcfa5334a90bc2a5399f32973d4eb5620
parente6dab9f62fbda86d0adb530f0c2a543e3e2ed118 (diff)
parent45a4f5d9f99334151af90b2199004ec49a651d7a (diff)
downloadgit-331f06d6f1cc0e164c4aa320c2659d99de67f2f6.tar.gz
Merge branch 'jk/difftool-command-not-found'
"git difftool" by default ignores the error exit from the backend commands it spawns, because often they signal that they found differences by exiting with a non-zero status code just like "diff" does; the exit status codes 126 and above however are special in that they are used to signal that the command is not executable, does not exist, or killed by a signal. "git difftool" has been taught to notice these exit status codes. * jk/difftool-command-not-found: difftool: always honor fatal error exit codes
-rwxr-xr-xgit-difftool--helper.sh7
-rwxr-xr-xt/t7800-difftool.sh6
2 files changed, 13 insertions, 0 deletions
diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh
index 84d6cc021c..7bfb6737df 100755
--- a/git-difftool--helper.sh
+++ b/git-difftool--helper.sh
@@ -86,6 +86,13 @@ else
do
launch_merge_tool "$1" "$2" "$5"
status=$?
+ if test $status -ge 126
+ then
+ # Command not found (127), not executable (126) or
+ # exited via a signal (>= 128).
+ exit $status
+ fi
+
if test "$status" != 0 &&
test "$GIT_DIFFTOOL_TRUST_EXIT_CODE" = true
then
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 2974900578..70a2de461a 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -124,6 +124,12 @@ test_expect_success PERL 'difftool stops on error with --trust-exit-code' '
test_cmp expect actual
'
+test_expect_success PERL 'difftool honors exit status if command not found' '
+ test_config difftool.nonexistent.cmd i-dont-exist &&
+ test_config difftool.trustExitCode false &&
+ test_must_fail git difftool -y -t nonexistent branch
+'
+
test_expect_success PERL 'difftool honors --gui' '
difftool_test_setup &&
test_config merge.tool bogus-tool &&