Merge branch 'da/difftool'
authorJunio C Hamano <gitster@pobox.com>
Wed, 29 Oct 2014 17:09:35 +0000 (10:09 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Oct 2014 17:09:35 +0000 (10:09 -0700)
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

1  2 
git-difftool.perl
diff --combined git-difftool.perl
index 598fcc23b930832a8cd3cfcff0c0d0c84ecd32bc,9a1054a2bb9d72d10aeb88c6bdf1d47b0fde1a75..7df7c8a9a7c889fbf5f0b2d6e67be66bf6fea6b1
@@@ -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},
                '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})) {
                }
        }
  
+       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