{"thread":{"id":"18524","subject":"[PATCH v2] difftool: add various git-difftool tests","startedAt":"2009-03-25T03:58:29Z","lastAt":"2009-03-25T03:58:29Z","messageCount":1,"participants":["David Aguilar"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"109306","messageId":"1237953509-24307-1-git-send-email-davvid@gmail.com","threadId":"18524","inReplyTo":null,"subject":"[PATCH v2] difftool: add various git-difftool tests","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-25T03:58:29Z","receivedAt":"2009-03-25T03:58:29Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"t7800-difftool.sh tests the various command-line flags,\ngit-config variables, and environment settings supported by\ngit-difftool.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n t/t7800-difftool.sh |  139 +++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 139 insertions(+), 0 deletions(-)\n create mode 100755 t/t7800-difftool.sh\n\ndiff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\nnew file mode 100755\nindex 0000000..ceef84b\n--- /dev/null\n+++ b/t/t7800-difftool.sh\n@@ -0,0 +1,139 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 David Aguilar\n+#\n+\n+test_description='git-difftool\n+\n+Testing basic diff tool invocation\n+'\n+\n+. ./test-lib.sh\n+\n+remove_config_vars()\n+{\n+\t# Unset all config variables used by git-difftool\n+\tgit config --unset diff.tool\n+\tgit config --unset difftool.test-tool.cmd\n+\tgit config --unset merge.tool\n+\tgit config --unset mergetool.test-tool.cmd\n+\treturn 0\n+}\n+\n+restore_test_defaults()\n+{\n+\t# Restores the test defaults used by several tests\n+\tremove_config_vars\n+\tunset GIT_DIFF_TOOL\n+\tunset GIT_MERGE_TOOL\n+\tunset GIT_DIFFTOOL_NO_PROMPT\n+\tgit config diff.tool test-tool &&\n+\tgit config difftool.test-tool.cmd 'cat $LOCAL'\n+}\n+\n+# Create a file on master and change it on branch\n+test_expect_success 'setup' '\n+\techo master >file &&\n+\tgit add file &&\n+\tgit commit -m \"added file\" &&\n+\n+\tgit checkout -b branch master &&\n+\techo branch >file &&\n+\tgit commit -a -m \"branch changed file\" &&\n+\tgit checkout master\n+'\n+\n+# Configure a custom difftool.<tool>.cmd and use it\n+test_expect_success 'custom commands' '\n+\trestore_test_defaults &&\n+\tgit config difftool.test-tool.cmd \"cat \\$REMOTE\" &&\n+\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"master\" &&\n+\n+\trestore_test_defaults &&\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\"\n+'\n+\n+# Ensures that git-difftool ignores bogus --tool values\n+test_expect_success 'difftool ignores bad --tool values' '\n+\tdiff=$(git difftool --no-prompt --tool=bogus-tool branch)\n+\ttest \"$?\" = 1 &&\n+\ttest \"$diff\" = \"\"\n+'\n+\n+# Specify the diff tool using $GIT_DIFF_TOOL\n+test_expect_success 'GIT_DIFF_TOOL variable' '\n+\tgit config --unset diff.tool\n+\tGIT_DIFF_TOOL=test-tool &&\n+\texport GIT_DIFF_TOOL &&\n+\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+# Test the $GIT_*_TOOL variables and ensure\n+# that $GIT_DIFF_TOOL always wins unless --tool is specified\n+test_expect_success 'GIT_DIFF_TOOL overrides' '\n+\tgit config diff.tool bogus-tool &&\n+\tgit config merge.tool bogus-tool &&\n+\n+\tGIT_MERGE_TOOL=test-tool &&\n+\texport GIT_MERGE_TOOL &&\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\tunset GIT_MERGE_TOOL &&\n+\n+\tGIT_MERGE_TOOL=bogus-tool &&\n+\tGIT_DIFF_TOOL=test-tool &&\n+\texport GIT_MERGE_TOOL &&\n+\texport GIT_DIFF_TOOL &&\n+\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\tGIT_DIFF_TOOL=bogus-tool &&\n+\texport GIT_DIFF_TOOL &&\n+\n+\tdiff=$(git difftool --no-prompt --tool=test-tool branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+# Test that we don't have to pass --no-prompt to difftool\n+# when $GIT_DIFFTOOL_NO_PROMPT is true\n+test_expect_success 'GIT_DIFFTOOL_NO_PROMPT variable' '\n+\tGIT_DIFFTOOL_NO_PROMPT=true &&\n+\texport GIT_DIFFTOOL_NO_PROMPT &&\n+\n+\tdiff=$(git difftool branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+# git-difftool falls back to git-mergetool config variables\n+# so test that behavior here\n+test_expect_success 'difftool + mergetool config variables' '\n+\tremove_config_vars\n+\tgit config merge.tool test-tool &&\n+\tgit config mergetool.test-tool.cmd \"cat \\$LOCAL\" &&\n+\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\t# set merge.tool to something bogus, diff.tool to test-tool\n+\tgit config merge.tool bogus-tool &&\n+\tgit config diff.tool test-tool &&\n+\n+\tdiff=$(git difftool --no-prompt branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\n+'\n+\n+test_done\n-- \n1.6.2.1.303.g63699\n"}]}