{"thread":{"id":"22012","subject":"[RFC PATCH 2/2] git-difftool: Add '--gui' for selecting a GUI tool","startedAt":"2009-12-23T05:27:13Z","lastAt":"2009-12-23T05:27:14Z","messageCount":2,"participants":["David Aguilar"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"130272","messageId":"1261546034-7780-1-git-send-email-davvid@gmail.com","threadId":"22012","inReplyTo":null,"subject":"[PATCH 1/2] t7800-difftool: Set a bogus tool for use by tests","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-12-23T05:27:13Z","receivedAt":"2009-12-23T05:27:13Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"If a difftool test has an error then running the git test suite\nmay end up invoking a GUI diff tool.  We now guard against this\nby setting a difftool.bogus-tool.cmd variable.\n\nThe tests already used --tool=bogus-tool in various places so\nthis is simply ensuring that nothing ever falls back and\nfinds a real diff tool.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n t/t7800-difftool.sh |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\nindex fff6a6d..707a0f5 100755\n--- a/t/t7800-difftool.sh\n+++ b/t/t7800-difftool.sh\n@@ -36,6 +36,7 @@ restore_test_defaults()\n \tunset GIT_DIFFTOOL_NO_PROMPT\n \tgit config diff.tool test-tool &&\n \tgit config difftool.test-tool.cmd 'cat $LOCAL'\n+\tgit config difftool.bogus-tool.cmd false\n }\n \n prompt_given()\n@@ -71,7 +72,7 @@ test_expect_success 'custom commands' '\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+\tdiff=$(git difftool --no-prompt --tool=bad-tool branch)\n \ttest \"$?\" = 1 &&\n \ttest \"$diff\" = \"\"\n '\n-- \n1.6.2.5\n"},{"id":"130271","messageId":"1261546034-7780-2-git-send-email-davvid@gmail.com","threadId":"22012","inReplyTo":"1261546034-7780-1-git-send-email-davvid@gmail.com","subject":"[RFC PATCH 2/2] git-difftool: Add '--gui' for selecting a GUI tool","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-12-23T05:27:14Z","receivedAt":"2009-12-23T05:27:14Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Users might prefer to have git-difftool use a different\ntool when run from a Git GUI.\n\nThis teaches git-difftool to honor 'diff.guitool' when\nthe '--gui' option is specified.  This allows users to\nconfigure their preferred command-line diff tool in\n'diff.tool' and a GUI diff tool in 'diff.guitool'.\n\nReference: http://article.gmane.org/gmane.comp.version-control.git/133386\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n\nThis is an RFC patch for a number of reasons.\n\n* We're in RC freeze\n* This introduces a new 'diff.guitool' variable.\n  I don't know if the name of the variable is desirable as-is.\n\nSo, I figured it's best to mark it as an RFC for now.\n\n Documentation/git-difftool.txt |    9 +++++++++\n git-difftool.perl              |   13 ++++++++++++-\n t/t7800-difftool.sh            |   12 ++++++++++++\n 3 files changed, 33 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt\nindex 8e9aed6..a5bce62 100644\n--- a/Documentation/git-difftool.txt\n+++ b/Documentation/git-difftool.txt\n@@ -58,6 +58,12 @@ 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+-g::\n+--gui::\n+\tWhen 'git-difftool' is invoked with the `-g` or `--gui` option\n+\tthe default diff tool will be read from the configured\n+\t`diff.guitool` variable instead of `diff.tool`.\n+\n See linkgit:git-diff[1] for the full list of supported options.\n \n CONFIG VARIABLES\n@@ -68,6 +74,9 @@ difftool equivalents have not been defined.\n diff.tool::\n \tThe default diff tool to use.\n \n+diff.guitool::\n+\tThe default diff tool to use when `--gui` is specified.\n+\n difftool.<tool>.path::\n \tOverride the path for the given tool.  This is useful in case\n \tyour tool is not in the PATH.\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex ba5e60a..8c836e4 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -15,13 +15,16 @@ use warnings;\n use Cwd qw(abs_path);\n use File::Basename qw(dirname);\n \n+require Git;\n+\n my $DIR = abs_path(dirname($0));\n \n \n sub usage\n {\n \tprint << 'USAGE';\n-usage: git difftool [--tool=<tool>] [-y|--no-prompt] [\"git diff\" options]\n+usage: git difftool [-g|--gui] [-t|--tool=<tool>] [-y|--no-prompt]\n+                    [\"git diff\" options]\n USAGE\n \texit 1;\n }\n@@ -63,6 +66,14 @@ sub generate_command\n \t\t\t$ENV{GIT_DIFF_TOOL} = substr($arg, 7);\n \t\t\tnext;\n \t\t}\n+\t\tif ($arg eq '-g' || $arg eq '--gui') {\n+\t\t\tmy $tool = Git::command_oneline('config',\n+\t\t\t                                'diff.guitool');\n+\t\t\tif (length($tool)) {\n+\t\t\t\t$ENV{GIT_DIFF_TOOL} = $tool;\n+\t\t\t}\n+\t\t\tnext;\n+\t\t}\n \t\tif ($arg eq '-y' || $arg eq '--no-prompt') {\n \t\t\t$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';\n \t\t\tdelete $ENV{GIT_DIFFTOOL_PROMPT};\ndiff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh\nindex 707a0f5..9bf6c98 100755\n--- a/t/t7800-difftool.sh\n+++ b/t/t7800-difftool.sh\n@@ -19,6 +19,7 @@ remove_config_vars()\n {\n \t# Unset all config variables used by git-difftool\n \tgit config --unset diff.tool\n+\tgit config --unset diff.guitool\n \tgit config --unset difftool.test-tool.cmd\n \tgit config --unset difftool.prompt\n \tgit config --unset merge.tool\n@@ -77,6 +78,17 @@ test_expect_success 'difftool ignores bad --tool values' '\n \ttest \"$diff\" = \"\"\n '\n \n+test_expect_success 'difftool honors --gui' '\n+\tgit config merge.tool bogus-tool &&\n+\tgit config diff.tool bogus-tool &&\n+\tgit config diff.guitool test-tool &&\n+\n+\tdiff=$(git difftool --no-prompt --gui branch) &&\n+\ttest \"$diff\" = \"branch\" &&\n+\n+\trestore_test_defaults\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-- \n1.6.2.5\n"}]}