From: Junio C Hamano Date: Wed, 29 Oct 2014 17:09:35 +0000 (-0700) Subject: Merge branch 'da/difftool' X-Git-Tag: v2.2.0-rc0~8 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9ce57f12280eb6a95043e28ad68ff2b6c70c09ad?ds=inline;hp=-c Merge branch 'da/difftool' Allow diff tool backend to stop early by exiting with a non-zero status. * da/difftool: difftool: add support for --trust-exit-code difftool--helper: exit when reading a prompt answer fails --- 9ce57f12280eb6a95043e28ad68ff2b6c70c09ad diff --combined git-difftool.perl index 598fcc23b9,9a1054a2bb..7df7c8a9a7 --- a/git-difftool.perl +++ b/git-difftool.perl @@@ -47,9 -47,13 +47,9 @@@ sub find_worktre sub print_tool_help { - my $cmd = 'TOOL_MODE=diff'; - $cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"'; - $cmd .= ' && show_tool_help'; - # See the comment at the bottom of file_diff() for the reason behind # using system() followed by exit() instead of exec(). - my $rc = system('sh', '-c', $cmd); + my $rc = system(qw(git mergetool --tool-help=diff)); exit($rc | ($rc >> 8)); } @@@ -342,6 -346,7 +342,7 @@@ sub mai 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}, @@@ -352,6 -357,8 +353,8 @@@ '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})) { @@@ -383,6 -390,15 +386,15 @@@ } } + 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