git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 13/9 v5] difftool: add '--no-gui' as an option

From
Tim Henigan <tim.henigan@gmail.com>
Date
Mar 22, 2012, 15:02 UTC
Message-ID
<1332428541-24878-3-git-send-email-tim.henigan@gmail.com>
In-Reply-To
<1332428541-24878-1-git-send-email-tim.henigan@gmail.com>

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>
---

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
Previous: Tim Henigan
Message 3 of 3 in “difftool: fix regression in '--prompt' options”
  1. 10/9 difftool: fix regression in '--prompt' optionsTim Henigan, Mar 22, 2012
  2. 12/9 t7800: add tests for difftool --dir-diffTim Henigan, Mar 22, 2012
  3. 13/9 difftool: add '--no-gui' as an optionTim Henigan, Mar 22, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.