difftool: add '--no-gui' option
This commit teaches difftool to handle the '--no-gui' option. This option negates the existing '--gui' option. The last setting given on the command line wins. This allows a user to configure "[alias] mdt = difftool --gui", but still have the ability to override the setting without error: $ git mdt --no-gui Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tim Henigan committed
Mar 22, 2012 at 15:52 UTC
850896042a42c1c16912a3981ca844e2cbcd14d4
2 files changed
+17
-3
git-difftool.perl
+4
-3
@@ -22,7 +22,8 @@ sub usage
22
{
23
print << 'USAGE';
24
usage: git difftool [-t|--tool=<tool>]
25
- [-x|--extcmd=<cmd>] [-g|--gui]
25
+ [-x|--extcmd=<cmd>]
26
+ [-g|--gui] [--no-gui]
27
[--prompt] [-y|--no-prompt]
28
['git diff' options]
29
USAGE
@@ -49,7 +50,7 @@ sub exe
50
# parse command-line options. all unrecognized options and arguments
51
# are passed through to the 'git diff' command.
52
my ($difftool_cmd, $extcmd, $gui, $help, $prompt);
52
-GetOptions('g|gui' => \$gui,
53
+GetOptions('g|gui!' => \$gui,
54
'h' => \$help,
55
'prompt!' => \$prompt,
56
'y' => sub { $prompt = 0; },
@@ -75,7 +76,7 @@ if (defined($extcmd)) {
76
usage();
77
}
78
}
78
-if (defined($gui)) {
79
+if ($gui) {
80
my $guitool = "";
81
$guitool = Git::config('diff.guitool');
82
if (length($guitool) > 0) {
t/t7800-difftool.sh
+13
@@ -94,6 +94,19 @@ test_expect_success PERL 'difftool honors --gui' '
94
restore_test_defaults
95
'
96
97
+test_expect_success PERL 'difftool --gui last setting wins' '
98
+ git config diff.guitool bogus-tool &&
99
+ git difftool --no-prompt --gui --no-gui &&
100
+
101
+ git config merge.tool bogus-tool &&
102
+ git config diff.tool bogus-tool &&
103
+ git config diff.guitool test-tool &&
104
+ diff=$(git difftool --no-prompt --no-gui --gui branch) &&
105
+ test "$diff" = "branch" &&
106
+
107
+ restore_test_defaults
108
+'
109
+
110
test_expect_success PERL 'difftool --gui works without configured diff.guitool' '
111
git config diff.tool test-tool &&
112