{"thread":{"id":"18481","subject":"[PATCH] difftool: add git-difftool to the list of commands","startedAt":"2009-03-23T08:41:15Z","lastAt":"2009-03-25T03:57:32Z","messageCount":4,"participants":["David Aguilar","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"109020","messageId":"1237797676-32047-1-git-send-email-davvid@gmail.com","threadId":"18481","inReplyTo":null,"subject":"[PATCH] difftool: add git-difftool to the list of commands","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-23T08:41:15Z","receivedAt":"2009-03-23T08:41:15Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Signed-off-by: David Aguilar <davvid@gmail.com>\n---\n command-list.txt |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/command-list.txt b/command-list.txt\nindex 3583a33..fb03a2e 100644\n--- a/command-list.txt\n+++ b/command-list.txt\n@@ -33,6 +33,7 @@ git-diff                                mainporcelain common\n git-diff-files                          plumbinginterrogators\n git-diff-index                          plumbinginterrogators\n git-diff-tree                           plumbinginterrogators\n+git-difftool                            ancillaryinterrogators\n git-fast-export\t\t\t\tancillarymanipulators\n git-fast-import\t\t\t\tancillarymanipulators\n git-fetch                               mainporcelain common\n-- \n1.6.2.1.303.g63699\n"},{"id":"109021","messageId":"1237797676-32047-2-git-send-email-davvid@gmail.com","threadId":"18481","inReplyTo":"1237797676-32047-1-git-send-email-davvid@gmail.com","subject":"[PATCH] difftool: add various git-difftool tests","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-23T08:41:16Z","receivedAt":"2009-03-23T08:41:16Z","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..c7cd2b1\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"},{"id":"109296","messageId":"7vr60m9vca.fsf@gitster.siamese.dyndns.org","threadId":"18481","inReplyTo":"1237797676-32047-2-git-send-email-davvid@gmail.com","subject":"Re: [PATCH] difftool: add various git-difftool tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-25T02:42:29Z","receivedAt":"2009-03-25T02:42:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\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\nI thought some shells' \"unset\" returns non-zero status when is given an\nalready unset variable.  I suspect you would want to drop the && chain\njust like you did for remove_config_vars for the same reason.\n\n> +\tgit config diff.tool test-tool &&\n> +\tgit config difftool.test-tool.cmd \"cat \\$LOCAL\"\n> +}\n\n'cat $LOCAL' would be much easier to read, wouldn't it?\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\nYou might want to lose && here in case the user told an earlier test that\nsets the configuration to some value skipped (or such test failed), or\nperhaps later somebody adds tests before this one that leaves the config\nwithout this variable.\n\nOther than that I didn't see major breakages.\n\nThanks.\n"},{"id":"109305","messageId":"402731c90903242057g47cdcb2an39bbd95ff80584c6@mail.gmail.com","threadId":"18481","inReplyTo":"7vr60m9vca.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] difftool: add various git-difftool tests","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-03-25T03:57:32Z","receivedAt":"2009-03-25T03:57:32Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Tue, Mar 24, 2009 at 7:42 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> David Aguilar <davvid@gmail.com> writes:\n>\n>> +remove_config_vars()\n>> +{\n>> +     # Unset all config variables used by git-difftool\n>> +     git config --unset diff.tool\n>> +     git config --unset difftool.test-tool.cmd\n>> +     git config --unset merge.tool\n>> +     git config --unset mergetool.test-tool.cmd\n>> +     return 0\n>> +}\n>> +\n>> +restore_test_defaults()\n>> +{\n>> +     # Restores the test defaults used by several tests\n>> +     remove_config_vars\n>> +     unset GIT_DIFF_TOOL &&\n>> +     unset GIT_MERGE_TOOL &&\n>> +     unset GIT_DIFFTOOL_NO_PROMPT &&\n>\n> I thought some shells' \"unset\" returns non-zero status when is given an\n> already unset variable.  I suspect you would want to drop the && chain\n> just like you did for remove_config_vars for the same reason.\n\n\nAh, I learn something new everyday.  Thanks.\nI've addressed these notes and am sending patch v2 now.\n\n\n\n>\n>> +     git config diff.tool test-tool &&\n>> +     git config difftool.test-tool.cmd \"cat \\$LOCAL\"\n>> +}\n>\n> 'cat $LOCAL' would be much easier to read, wouldn't it?\n>\n>> + ...\n>> +# Specify the diff tool using $GIT_DIFF_TOOL\n>> +test_expect_success 'GIT_DIFF_TOOL variable' '\n>> +     git config --unset diff.tool &&\n>\n> You might want to lose && here in case the user told an earlier test that\n> sets the configuration to some value skipped (or such test failed), or\n> perhaps later somebody adds tests before this one that leaves the config\n> without this variable.\n>\n> Other than that I didn't see major breakages.\n>\n> Thanks.\n>\n\n\n\n-- \n    David\n"}]}