From 23218bbd2ea7f919b93245489e544a55165ec466 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Tue, 22 Dec 2009 21:27:13 -0800 Subject: 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. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- t/t7800-difftool.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index fff6a6d0e..707a0f54a 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -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" = "" ' -- cgit v1.2.1 From 4cefa495ca91ad833084ebf3f73c77997920ae9b Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Tue, 22 Dec 2009 21:27:14 -0800 Subject: 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 Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- t/t7800-difftool.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 't') diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 707a0f54a..9bf6c98c5 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -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 -- cgit v1.2.1 From 61ed71dcff8448b0700ef032aa1f962649306624 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 9 Jan 2010 20:02:41 -0800 Subject: difftool--helper: Remove use of the GIT_MERGE_TOOL variable An undocumented mis-feature in git-difftool is that it allows you to specify a default difftool by setting GIT_MERGE_TOOL. This behavior was never documented and was included as an oversight back when git-difftool was maintained outside of git. git-mergetool never honored GIT_MERGE_TOOL so neither should git-difftool. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- t/t7800-difftool.sh | 9 --------- 1 file changed, 9 deletions(-) (limited to 't') diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 9bf6c98c5..eca51a8fe 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -32,7 +32,6 @@ restore_test_defaults() # Restores the test defaults used by several tests remove_config_vars unset GIT_DIFF_TOOL - unset GIT_MERGE_TOOL unset GIT_DIFFTOOL_PROMPT unset GIT_DIFFTOOL_NO_PROMPT git config diff.tool test-tool && @@ -107,15 +106,7 @@ test_expect_success 'GIT_DIFF_TOOL overrides' ' git config diff.tool bogus-tool && git config merge.tool bogus-tool && - GIT_MERGE_TOOL=test-tool && - export GIT_MERGE_TOOL && - diff=$(git difftool --no-prompt branch) && - test "$diff" = "branch" && - unset GIT_MERGE_TOOL && - - GIT_MERGE_TOOL=bogus-tool && GIT_DIFF_TOOL=test-tool && - export GIT_MERGE_TOOL && export GIT_DIFF_TOOL && diff=$(git difftool --no-prompt branch) && -- cgit v1.2.1 From 1c6f5b52b7b13bbc6cf404cb5ef9e64fda37655c Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Sat, 9 Jan 2010 20:02:42 -0800 Subject: difftool: Allow specifying unconfigured commands with --extcmd git-difftool requires difftool..cmd configuration even when tools use the standard "$diffcmd $from $to" form. This teaches git-difftool to run these tools in lieu of configuration by allowing the command to be specified on the command line. Reference: http://article.gmane.org/gmane.comp.version-control.git/133377 Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- t/t7800-difftool.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 't') diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index eca51a8fe..8ee186a5f 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -214,7 +214,24 @@ test_expect_success 'difftool..path' ' diff=$(git difftool --tool=tkdiff --no-prompt branch) && git config --unset difftool.tkdiff.path && lines=$(echo "$diff" | grep file | wc -l) && - test "$lines" -eq 1 + test "$lines" -eq 1 && + + restore_test_defaults +' + +test_expect_success 'difftool --extcmd=...' ' + diff=$(git difftool --no-prompt --extcmd=cat branch) && + + lines=$(echo "$diff" | wc -l) && + test "$lines" -eq 2 && + + lines=$(echo "$diff" | grep master | wc -l) && + test "$lines" -eq 1 && + + lines=$(echo "$diff" | grep branch | wc -l) && + test "$lines" -eq 1 && + + restore_test_defaults ' test_done -- cgit v1.2.1 From a9e11220c2656cc5d7baac4d0735c04f9be46438 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Fri, 15 Jan 2010 14:03:42 -0800 Subject: t7800-difftool.sh: Simplify the --extcmd test Instead of running 'grep', 'echo', and 'wc' we simply compare git-difftool's output against a known good value. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- t/t7800-difftool.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 't') diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 8ee186a5f..1d9e07b0d 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -15,6 +15,9 @@ if ! test_have_prereq PERL; then test_done fi +LF=' +' + remove_config_vars() { # Unset all config variables used by git-difftool @@ -219,19 +222,13 @@ test_expect_success 'difftool..path' ' restore_test_defaults ' -test_expect_success 'difftool --extcmd=...' ' +test_expect_success 'difftool --extcmd=cat' ' diff=$(git difftool --no-prompt --extcmd=cat branch) && + test "$diff" = branch"$LF"master - lines=$(echo "$diff" | wc -l) && - test "$lines" -eq 2 && - lines=$(echo "$diff" | grep master | wc -l) && - test "$lines" -eq 1 && - lines=$(echo "$diff" | grep branch | wc -l) && - test "$lines" -eq 1 && - restore_test_defaults ' test_done -- cgit v1.2.1 From f47f1e2ce8b4022113120b32decb4436341dc3aa Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Fri, 15 Jan 2010 14:03:43 -0800 Subject: difftool: Add '-x' and as an alias for '--extcmd' This adds '-x' as a shorthand for the '--extcmd' option. Arguments to '--extcmd' can be specified separately, which was not originally possible. This also fixes the brief help text so that it mentions both '-x' and '--extcmd'. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- t/t7800-difftool.sh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 't') diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 1d9e07b0d..69e1c3415 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -225,8 +225,16 @@ test_expect_success 'difftool..path' ' test_expect_success 'difftool --extcmd=cat' ' diff=$(git difftool --no-prompt --extcmd=cat branch) && test "$diff" = branch"$LF"master +' +test_expect_success 'difftool --extcmd cat' ' + diff=$(git difftool --no-prompt --extcmd cat branch) && + test "$diff" = branch"$LF"master +' +test_expect_success 'difftool -x cat' ' + diff=$(git difftool --no-prompt -x cat branch) && + test "$diff" = branch"$LF"master ' -- cgit v1.2.1 From 9f3d54d193d9edcf443c9dd62789af5e8e47635c Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Fri, 15 Jan 2010 14:03:44 -0800 Subject: difftool: Use eval to expand '--extcmd' expressions It was not possible to pass quoted commands to '--extcmd'. By using 'eval' we ensure that expressions with spaces and quotes are supported. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- t/t7800-difftool.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 't') diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 69e1c3415..a183f1db4 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -235,8 +235,21 @@ test_expect_success 'difftool --extcmd cat' ' test_expect_success 'difftool -x cat' ' diff=$(git difftool --no-prompt -x cat branch) && test "$diff" = branch"$LF"master +' + +test_expect_success 'difftool --extcmd echo arg1' ' + diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"echo\ \$1\" branch) + test "$diff" = file +' +test_expect_success 'difftool --extcmd cat arg1' ' + diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"cat\ \$1\" branch) + test "$diff" = master +' +test_expect_success 'difftool --extcmd cat arg2' ' + diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"cat\ \$2\" branch) + test "$diff" = branch ' test_done -- cgit v1.2.1 From c8a5672ea5cf593708b29f8279bd651c16047c6e Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Fri, 15 Jan 2010 19:10:03 -0800 Subject: difftool: Update copyright notices to list each year separately This is http://www.gnu.org/licenses/gpl-howto.html advises. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- t/t7800-difftool.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index a183f1db4..fad547225 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2009 David Aguilar +# Copyright (c) 2009, 2010 David Aguilar # test_description='git-difftool -- cgit v1.2.1