X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft7800-difftool.sh;h=19c72f55bf60c746f72e640e24043b2d83e00fe3;hb=801bad3ba4eb5014d402201c85c61a969436adf0;hp=fff6a6d0eab4b27d5bc7ff4636913cb10296ab7b;hpb=1f73566af5bec28cd8489c6139a9ede95817349c;p=git.git diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index fff6a6d0e..19c72f55b 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 @@ -15,14 +15,19 @@ if ! test_have_prereq PERL; then test_done fi +LF=' +' + 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 git config --unset mergetool.test-tool.cmd + git config --unset mergetool.prompt return 0 } @@ -31,11 +36,11 @@ 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 && git config difftool.test-tool.cmd 'cat $LOCAL' + git config difftool.bogus-tool.cmd false } prompt_given() @@ -71,11 +76,22 @@ 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" = "" ' +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 @@ -94,15 +110,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) && @@ -152,6 +160,17 @@ test_expect_success 'difftool.prompt config variable is false' ' restore_test_defaults ' +# Test that we don't have to pass --no-prompt when mergetool.prompt is false +test_expect_success 'difftool merge.prompt = false' ' + git config --unset difftool.prompt + git config mergetool.prompt false && + + diff=$(git difftool branch) && + test "$diff" = "branch" && + + restore_test_defaults +' + # Test that the -y flag can override difftool.prompt = true test_expect_success 'difftool.prompt can overridden with -y' ' git config difftool.prompt true && @@ -210,7 +229,39 @@ 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=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 +' + +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