t7800-difftool: Set a bogus tool for use by tests
PATCH 1/2 t7800-difftool: Set a bogus tool for use by tests
If a difftool test has an error then running the git test suite may end up invoking a GUI diff tool. We now guard against this by setting a difftool.bogus-tool.cmd variable.
The tests already used --tool=bogus-tool in various places so this is simply ensuring that nothing ever falls back and finds a real diff tool.
--- t/t7800-difftool.sh | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
t/t7800-difftool.sh +2 -1
@@ -36,6 +36,7 @@ restore_test_defaults() unset GIT_DIFFTOOL_NO_PROMPT git config diff.tool test-tool && git config difftool.test-tool.cmd 'cat $LOCAL' + git config difftool.bogus-tool.cmd false } prompt_given()
@@ -71,7 +72,7 @@ test_expect_success 'custom commands' ' # Ensures that git-difftool ignores bogus --tool values test_expect_success 'difftool ignores bad --tool values' ' - diff=$(git difftool --no-prompt --tool=bogus-tool branch) + diff=$(git difftool --no-prompt --tool=bad-tool branch) test "$?" = 1 && test "$diff" = "" '
Signature · 1 line
1.6.2.5
RFC PATCH 2/2 git-difftool: Add '--gui' for selecting a GUI tool
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
---
This is an RFC patch for a number of reasons.
* We're in RC freeze
* This introduces a new 'diff.guitool' variable.
I don't know if the name of the variable is desirable as-is.
So, I figured it's best to mark it as an RFC for now.
Documentation/git-difftool.txt | 9 +++++++++ git-difftool.perl | 13 ++++++++++++- t/t7800-difftool.sh | 12 ++++++++++++ 3 files changed, 33 insertions(+), 1 deletions(-)
Documentation/git-difftool.txt +9 -0
@@ -58,6 +58,12 @@ is set to the name of the temporary file containing the contents 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
@@ -68,6 +74,9 @@ difftool equivalents have not been defined. 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.
git-difftool.perl +12 -1
@@ -15,13 +15,16 @@ use warnings; 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; }
@@ -63,6 +66,14 @@ sub generate_command $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};
t/t7800-difftool.sh +12 -0
@@ -19,6 +19,7 @@ remove_config_vars() { # 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
@@ -77,6 +78,17 @@ test_expect_success 'difftool ignores bad --tool values' ' 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
Signature · 1 line
1.6.2.5