[PATCH 13/9 v5] difftool: add '--no-gui' as an option
From: Tim Henigan <hidden>
Date: 2016-06-15 22:53:21
Subsystem:
the rest · Maintainer:
Linus Torvalds
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 <redacted> --- This patch is new to the series. It fixes a potential bug pointed out by Junio Hamano on the Git developers list [1]. [1]: http://thread.gmane.org/gmane.comp.version-control.git/193601/focus=193633 git-difftool.perl | 7 ++++--- t/t7800-difftool.sh | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index 9892d1e..d9be7d6 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl@@ -29,7 +29,8 @@ sub usage my $exitcode = shift; print << 'USAGE'; usage: git difftool [-t|--tool=<tool>] [--tool-help] - [-x|--extcmd=<cmd>] [-g|--gui] + [-x|--extcmd=<cmd>] + [-g|--gui] [--no-gui] [--prompt] [-y|--no-prompt] [-d|--dir-diff] ['git diff' options]
@@ -132,7 +133,7 @@ sub setup_dir_diff # parse command-line options. all unrecognized options and arguments # are passed through to the 'git diff' command. my ($difftool_cmd, $dirdiff, $extcmd, $gui, $help, $prompt, $tool_help); -GetOptions('g|gui' => \$gui, +GetOptions('g|gui!' => \$gui, 'd|dir-diff' => \$dirdiff, 'h' => \$help, 'prompt!' => \$prompt,
@@ -169,7 +170,7 @@ if (defined($extcmd)) { usage(1); } } -if (defined($gui)) { +if ($gui) { my $guitool = ""; $guitool = Git::config('diff.guitool'); if (length($guitool) > 0) {
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 5f3ad3f..bbe71e5 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh@@ -94,6 +94,19 @@ test_expect_success PERL 'difftool honors --gui' ' 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 &&
--
1.7.10.rc1.40.g756bbcd