summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDavid Aguilar <davvid@gmail.com>2014-10-27 01:15:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-10-28 17:36:57 (GMT)
commit2b52123fcf840686b69e10807fd0f985ec4167f3 (patch)
tree34420488a17a99b950f100c1a2ac9e2596599480 /t
parent25098690a0151ba29ec1c728d783366c1899624d (diff)
downloadgit-2b52123fcf840686b69e10807fd0f985ec4167f3.zip
git-2b52123fcf840686b69e10807fd0f985ec4167f3.tar.gz
git-2b52123fcf840686b69e10807fd0f985ec4167f3.tar.bz2
difftool: add support for --trust-exit-code
Teach difftool to exit when a diff tool returns a non-zero exit code when either --trust-exit-code is specified or difftool.trustExitCode is true. Forward exit codes from invoked diff tools to the caller when --trust-exit-code is used. Suggested-by: Adri Farr <14farresa@gmail.com> Helped-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t7800-difftool.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 9cf5dc9..69bde7a 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -76,6 +76,49 @@ test_expect_success PERL 'difftool forwards arguments to diff' '
rm for-diff
'
+test_expect_success PERL 'difftool ignores exit code' '
+ test_config difftool.error.cmd false &&
+ git difftool -y -t error branch
+'
+
+test_expect_success PERL 'difftool forwards exit code with --trust-exit-code' '
+ test_config difftool.error.cmd false &&
+ test_must_fail git difftool -y --trust-exit-code -t error branch
+'
+
+test_expect_success PERL 'difftool honors difftool.trustExitCode = true' '
+ test_config difftool.error.cmd false &&
+ test_config difftool.trustExitCode true &&
+ test_must_fail git difftool -y -t error branch
+'
+
+test_expect_success PERL 'difftool honors difftool.trustExitCode = false' '
+ test_config difftool.error.cmd false &&
+ test_config difftool.trustExitCode false &&
+ git difftool -y -t error branch
+'
+
+test_expect_success PERL 'difftool ignores exit code with --no-trust-exit-code' '
+ test_config difftool.error.cmd false &&
+ test_config difftool.trustExitCode true &&
+ git difftool -y --no-trust-exit-code -t error branch
+'
+
+test_expect_success PERL 'difftool stops on error with --trust-exit-code' '
+ test_when_finished "rm -f for-diff .git/fail-right-file" &&
+ test_when_finished "git reset -- for-diff" &&
+ write_script .git/fail-right-file <<-\EOF &&
+ echo "$2"
+ exit 1
+ EOF
+ >for-diff &&
+ git add for-diff &&
+ echo file >expect &&
+ test_must_fail git difftool -y --trust-exit-code \
+ --extcmd .git/fail-right-file branch >actual &&
+ test_cmp expect actual
+'
+
test_expect_success PERL 'difftool honors --gui' '
difftool_test_setup &&
test_config merge.tool bogus-tool &&