{"thread":{"id":"22148","subject":"[PATCH 1/4] difftool--helper: Update copyright and remove distracting comments","startedAt":"2010-01-10T04:02:40Z","lastAt":"2010-01-10T04:02:43Z","messageCount":4,"participants":["David Aguilar"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"131202","messageId":"1263096163-15743-1-git-send-email-davvid@gmail.com","threadId":"22148","inReplyTo":null,"subject":"[PATCH 1/4] difftool--helper: Update copyright and remove distracting comments","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-01-10T04:02:40Z","receivedAt":"2010-01-10T04:02:40Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Some of the comments in git-difftool--helper are not needed because\nthe code is sufficiently readable without them.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-difftool--helper.sh |    5 +----\n 1 files changed, 1 insertions(+), 4 deletions(-)\n\ndiff --git a/git-difftool--helper.sh b/git-difftool--helper.sh\nindex 57e8e32..1b13808 100755\n--- a/git-difftool--helper.sh\n+++ b/git-difftool--helper.sh\n@@ -3,9 +3,8 @@\n # This script is typically launched by using the 'git difftool'\n # convenience command.\n #\n-# Copyright (c) 2009 David Aguilar\n+# Copyright (c) 2009-2010 David Aguilar\n \n-# Load common functions from git-mergetool--lib\n TOOL_MODE=diff\n . git-mergetool--lib\n \n@@ -20,7 +19,6 @@ should_prompt () {\n \tfi\n }\n \n-# Sets up shell variables and runs a merge tool\n launch_merge_tool () {\n \t# Merged is the filename as it appears in the work tree\n \t# Local is the contents of a/filename\n@@ -39,7 +37,6 @@ launch_merge_tool () {\n \t\tread ans\n \tfi\n \n-\t# Run the appropriate merge tool command\n \trun_merge_tool \"$merge_tool\"\n }\n \n-- \n1.6.6.4.g20a38b.dirty\n"},{"id":"131203","messageId":"1263096163-15743-2-git-send-email-davvid@gmail.com","threadId":"22148","inReplyTo":"1263096163-15743-1-git-send-email-davvid@gmail.com","subject":"[PATCH 2/4] difftool--helper: Remove use of the GIT_MERGE_TOOL variable","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-01-10T04:02:41Z","receivedAt":"2010-01-10T04:02:41Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"An undocumented mis-feature in git-difftool is that it allows you\nto specify a default difftool by setting GIT_MERGE_TOOL.\nThis behavior was never documented and was included as an\noversight back when git-difftool was maintained outside of git.\n\ngit-mergetool never honored GIT_MERGE_TOOL so neither should\ngit-difftool.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n git-difftool--helper.sh |    9 ++++-----\n t/t7800-difftool.sh     |    9 ---------\n 2 files changed, 4 insertions(+), 14 deletions(-)\n\ndiff --git a/git-difftool--helper.sh b/git-difftool--helper.sh\nindex 1b13808..3621f28 100755\n--- a/git-difftool--helper.sh\n+++ b/git-difftool--helper.sh\n@@ -40,11 +40,10 @@ launch_merge_tool () {\n \trun_merge_tool \"$merge_tool\"\n }\n \n-# Allow GIT_DIFF_TOOL and GIT_MERGE_TOOL to provide default values\n-test -n \"$GIT_MERGE_TOOL\" && merge_tool=\"$GIT_MERGE_TOOL\"\n-test -n \"$GIT_DIFF_TOOL\" && merge_tool=\"$GIT_DIFF_TOOL\"\n-\n-if test -z \"$merge_tool\"; then\n+# GIT_DIFF_TOOL indicates that --tool=... was specified\n+if test -n \"$GIT_DIFF_TOOL\"; then\n+\tmerge_tool=\"$GIT_DIFF_TOOL\"\n+else\n \tmerge_tool=\"$(get_merge_tool)\" || exit\n fi\n \ndiff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\nindex 9bf6c98..eca51a8 100755\n--- a/t/t7800-difftool.sh\n+++ b/t/t7800-difftool.sh\n@@ -32,7 +32,6 @@ restore_test_defaults()\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_PROMPT\n \tunset GIT_DIFFTOOL_NO_PROMPT\n \tgit config diff.tool test-tool &&\n@@ -107,15 +106,7 @@ 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-- \n1.6.6.4.g20a38b.dirty\n"},{"id":"131204","messageId":"1263096163-15743-3-git-send-email-davvid@gmail.com","threadId":"22148","inReplyTo":"1263096163-15743-1-git-send-email-davvid@gmail.com","subject":"[PATCH 3/4] difftool: Allow specifying unconfigured commands with --extcmd","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-01-10T04:02:42Z","receivedAt":"2010-01-10T04:02:42Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"git-difftool requires difftool.<tool>.cmd configuration even when\ntools use the standard \"$diffcmd $from $to\" form.  This teaches\ngit-difftool to run these tools in lieu of configuration by\nallowing the command to be specified on the command line.\n\nReference: http://article.gmane.org/gmane.comp.version-control.git/133377\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n Documentation/git-difftool.txt |    5 +++++\n git-difftool--helper.sh        |   30 +++++++++++++++++++++++-------\n git-difftool.perl              |    4 ++++\n t/t7800-difftool.sh            |   19 ++++++++++++++++++-\n 4 files changed, 50 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt\nindex a5bce62..f67d2db 100644\n--- a/Documentation/git-difftool.txt\n+++ b/Documentation/git-difftool.txt\n@@ -58,6 +58,11 @@ is set to the name of the temporary file containing the contents\n of the diff post-image.  `$BASE` is provided for compatibility\n with custom merge tool commands and has the same value as `$LOCAL`.\n \n+--extcmd=<command>::\n+\tSpecify a custom command for viewing diffs.\n+\t'git-difftool' ignores the configured defaults and runs\n+\t`$command $LOCAL $REMOTE` when this option is specified.\n+\n -g::\n --gui::\n \tWhen 'git-difftool' is invoked with the `-g` or `--gui` option\ndiff --git a/git-difftool--helper.sh b/git-difftool--helper.sh\nindex 3621f28..d806eae 100755\n--- a/git-difftool--helper.sh\n+++ b/git-difftool--helper.sh\n@@ -19,6 +19,11 @@ should_prompt () {\n \tfi\n }\n \n+# Indicates that --extcmd=... was specified\n+use_ext_cmd () {\n+\ttest -n \"$GIT_DIFFTOOL_EXTCMD\"\n+}\n+\n launch_merge_tool () {\n \t# Merged is the filename as it appears in the work tree\n \t# Local is the contents of a/filename\n@@ -33,18 +38,29 @@ launch_merge_tool () {\n \t# the user with the real $MERGED name before launching $merge_tool.\n \tif should_prompt; then\n \t\tprintf \"\\nViewing: '$MERGED'\\n\"\n-\t\tprintf \"Hit return to launch '%s': \" \"$merge_tool\"\n+\t\tif use_ext_cmd; then\n+\t\t\tprintf \"Hit return to launch '%s': \" \\\n+\t\t\t\t\"$GIT_DIFFTOOL_EXTCMD\"\n+\t\telse\n+\t\t\tprintf \"Hit return to launch '%s': \" \"$merge_tool\"\n+\t\tfi\n \t\tread ans\n \tfi\n \n-\trun_merge_tool \"$merge_tool\"\n+\tif use_ext_cmd; then\n+\t\t$GIT_DIFFTOOL_EXTCMD \"$LOCAL\" \"$REMOTE\"\n+\telse\n+\t\trun_merge_tool \"$merge_tool\"\n+\tfi\n+\n }\n \n-# GIT_DIFF_TOOL indicates that --tool=... was specified\n-if test -n \"$GIT_DIFF_TOOL\"; then\n-\tmerge_tool=\"$GIT_DIFF_TOOL\"\n-else\n-\tmerge_tool=\"$(get_merge_tool)\" || exit\n+if ! use_ext_cmd; then\n+\tif test -n \"$GIT_DIFF_TOOL\"; then\n+\t\tmerge_tool=\"$GIT_DIFF_TOOL\"\n+\telse\n+\t\tmerge_tool=\"$(get_merge_tool)\" || exit\n+\tfi\n fi\n \n # Launch the merge tool on each path provided by 'git diff'\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex 8c836e4..f8ff245 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -62,6 +62,10 @@ sub generate_command\n \t\t\t$skip_next = 1;\n \t\t\tnext;\n \t\t}\n+\t\tif ($arg =~ /^--extcmd=/) {\n+\t\t\t$ENV{GIT_DIFFTOOL_EXTCMD} = substr($arg, 9);\n+\t\t\tnext;\n+\t\t}\n \t\tif ($arg =~ /^--tool=/) {\n \t\t\t$ENV{GIT_DIFF_TOOL} = substr($arg, 7);\n \t\t\tnext;\ndiff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\nindex eca51a8..8ee186a 100755\n--- a/t/t7800-difftool.sh\n+++ b/t/t7800-difftool.sh\n@@ -214,7 +214,24 @@ test_expect_success 'difftool.<tool>.path' '\n \tdiff=$(git difftool --tool=tkdiff --no-prompt branch) &&\n \tgit config --unset difftool.tkdiff.path &&\n \tlines=$(echo \"$diff\" | grep file | wc -l) &&\n-\ttest \"$lines\" -eq 1\n+\ttest \"$lines\" -eq 1 &&\n+\n+\trestore_test_defaults\n+'\n+\n+test_expect_success 'difftool --extcmd=...' '\n+\tdiff=$(git difftool --no-prompt --extcmd=cat branch) &&\n+\n+\tlines=$(echo \"$diff\" | wc -l) &&\n+\ttest \"$lines\" -eq 2 &&\n+\n+\tlines=$(echo \"$diff\" | grep master | wc -l) &&\n+\ttest \"$lines\" -eq 1 &&\n+\n+\tlines=$(echo \"$diff\" | grep branch | wc -l) &&\n+\ttest \"$lines\" -eq 1 &&\n+\n+\trestore_test_defaults\n '\n \n test_done\n-- \n1.6.6.4.g20a38b.dirty\n"},{"id":"131205","messageId":"1263096163-15743-4-git-send-email-davvid@gmail.com","threadId":"22148","inReplyTo":"1263096163-15743-1-git-send-email-davvid@gmail.com","subject":"[PATCH 4/4] git-diff.txt: Link to git-difftool","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2010-01-10T04:02:43Z","receivedAt":"2010-01-10T04:02:43Z","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 Documentation/git-diff.txt |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt\nindex 0ac7112..723a648 100644\n--- a/Documentation/git-diff.txt\n+++ b/Documentation/git-diff.txt\n@@ -157,6 +157,10 @@ $ git diff -R                          <2>\n rewrites (very expensive).\n <2> Output diff in reverse.\n \n+SEE ALSO\n+--------\n+linkgit:git-difftool[1]::\n+\tShow changes using common diff tools\n \n Author\n ------\n-- \n1.6.6.4.g20a38b.dirty\n"}]}