summaryrefslogtreecommitdiff
path: root/git-difftool.perl
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 /git-difftool.perl
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 'git-difftool.perl')
-rwxr-xr-xgit-difftool.perl12
1 files changed, 12 insertions, 0 deletions
diff --git a/git-difftool.perl b/git-difftool.perl
index 18ca61e..9a1054a 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -346,6 +346,7 @@ sub main
symlinks => $^O ne 'cygwin' &&
$^O ne 'MSWin32' && $^O ne 'msys',
tool_help => undef,
+ trust_exit_code => undef,
);
GetOptions('g|gui!' => \$opts{gui},
'd|dir-diff' => \$opts{dirdiff},
@@ -356,6 +357,8 @@ sub main
'no-symlinks' => sub { $opts{symlinks} = 0; },
't|tool:s' => \$opts{difftool_cmd},
'tool-help' => \$opts{tool_help},
+ 'trust-exit-code' => \$opts{trust_exit_code},
+ 'no-trust-exit-code' => sub { $opts{trust_exit_code} = 0; },
'x|extcmd:s' => \$opts{extcmd});
if (defined($opts{help})) {
@@ -387,6 +390,15 @@ sub main
}
}
+ if (!defined $opts{trust_exit_code}) {
+ $opts{trust_exit_code} = Git::config_bool('difftool.trustExitCode');
+ }
+ if ($opts{trust_exit_code}) {
+ $ENV{GIT_DIFFTOOL_TRUST_EXIT_CODE} = 'true';
+ } else {
+ $ENV{GIT_DIFFTOOL_TRUST_EXIT_CODE} = 'false';
+ }
+
# In directory diff mode, 'git-difftool--helper' is called once
# to compare the a/b directories. In file diff mode, 'git diff'
# will invoke a separate instance of 'git-difftool--helper' for