{
print << 'USAGE';
usage: git difftool [-t|--tool=<tool>]
- [-x|--extcmd=<cmd>] [-g|--gui]
+ [-x|--extcmd=<cmd>]
+ [-g|--gui] [--no-gui]
[--prompt] [-y|--no-prompt]
['git diff' options]
USAGE
# parse command-line options. all unrecognized options and arguments
# are passed through to the 'git diff' command.
my ($difftool_cmd, $extcmd, $gui, $help, $prompt);
-GetOptions('g|gui' => \$gui,
+GetOptions('g|gui!' => \$gui,
'h' => \$help,
'prompt!' => \$prompt,
'y' => sub { $prompt = 0; },
usage();
}
}
-if (defined($gui)) {
+if ($gui) {
my $guitool = "";
$guitool = Git::config('diff.guitool');
if (length($guitool) > 0) {
restore_test_defaults
'
+test_expect_success PERL 'difftool --gui last setting wins' '
+ git config diff.guitool bogus-tool &&
+ git difftool --no-prompt --gui --no-gui &&
+
+ git config merge.tool bogus-tool &&
+ git config diff.tool bogus-tool &&
+ git config diff.guitool test-tool &&
+ diff=$(git difftool --no-prompt --no-gui --gui branch) &&
+ test "$diff" = "branch" &&
+
+ restore_test_defaults
+'
+
test_expect_success PERL 'difftool --gui works without configured diff.guitool' '
git config diff.tool test-tool &&