summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 23218bb)
raw | patch | inline | side by side (parent: 23218bb)
author | David Aguilar <davvid@gmail.com> | |
Wed, 23 Dec 2009 05:27:14 +0000 (21:27 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 3 Jan 2010 08:29:35 +0000 (00:29 -0800) |
Users might prefer to have git-difftool use a different
tool when run from a Git GUI.
This teaches git-difftool to honor 'diff.guitool' when
the '--gui' option is specified. This allows users to
configure their preferred command-line diff tool in
'diff.tool' and a GUI diff tool in 'diff.guitool'.
Reference: http://article.gmane.org/gmane.comp.version-control.git/133386
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tool when run from a Git GUI.
This teaches git-difftool to honor 'diff.guitool' when
the '--gui' option is specified. This allows users to
configure their preferred command-line diff tool in
'diff.tool' and a GUI diff tool in 'diff.guitool'.
Reference: http://article.gmane.org/gmane.comp.version-control.git/133386
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-difftool.txt | patch | blob | history | |
git-difftool.perl | patch | blob | history | |
t/t7800-difftool.sh | patch | blob | history |
index 8e9aed67d7f68c0234ee47dc147736bf3b8e5c4f..a5bce6278b6570e9feb94cfbe0f67f3814a36aa5 100644 (file)
of the diff post-image. `$BASE` is provided for compatibility
with custom merge tool commands and has the same value as `$LOCAL`.
+-g::
+--gui::
+ When 'git-difftool' is invoked with the `-g` or `--gui` option
+ the default diff tool will be read from the configured
+ `diff.guitool` variable instead of `diff.tool`.
+
See linkgit:git-diff[1] for the full list of supported options.
CONFIG VARIABLES
diff.tool::
The default diff tool to use.
+diff.guitool::
+ The default diff tool to use when `--gui` is specified.
+
difftool.<tool>.path::
Override the path for the given tool. This is useful in case
your tool is not in the PATH.
diff --git a/git-difftool.perl b/git-difftool.perl
index ba5e60a45e2c4a8b54e6a58e656b3978dcb45633..8c836e4c76528e52b010dd37e904f132d5386000 100755 (executable)
--- a/git-difftool.perl
+++ b/git-difftool.perl
use Cwd qw(abs_path);
use File::Basename qw(dirname);
+require Git;
+
my $DIR = abs_path(dirname($0));
sub usage
{
print << 'USAGE';
-usage: git difftool [--tool=<tool>] [-y|--no-prompt] ["git diff" options]
+usage: git difftool [-g|--gui] [-t|--tool=<tool>] [-y|--no-prompt]
+ ["git diff" options]
USAGE
exit 1;
}
$ENV{GIT_DIFF_TOOL} = substr($arg, 7);
next;
}
+ if ($arg eq '-g' || $arg eq '--gui') {
+ my $tool = Git::command_oneline('config',
+ 'diff.guitool');
+ if (length($tool)) {
+ $ENV{GIT_DIFF_TOOL} = $tool;
+ }
+ next;
+ }
if ($arg eq '-y' || $arg eq '--no-prompt') {
$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
delete $ENV{GIT_DIFFTOOL_PROMPT};
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 707a0f54ae85a6095c57e2598bb5cd3fd83bceb3..9bf6c98c54f368dfc837a8c5c374021269f20707 100755 (executable)
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
{
# Unset all config variables used by git-difftool
git config --unset diff.tool
+ git config --unset diff.guitool
git config --unset difftool.test-tool.cmd
git config --unset difftool.prompt
git config --unset merge.tool
test "$diff" = ""
'
+test_expect_success 'difftool honors --gui' '
+ git config merge.tool bogus-tool &&
+ git config diff.tool bogus-tool &&
+ git config diff.guitool test-tool &&
+
+ diff=$(git difftool --no-prompt --gui branch) &&
+ test "$diff" = "branch" &&
+
+ restore_test_defaults
+'
+
# Specify the diff tool using $GIT_DIFF_TOOL
test_expect_success 'GIT_DIFF_TOOL variable' '
git config --unset diff.tool