{"thread":{"id":"29971","subject":"[PATCH 9/9] difftool: print list of valid tools with '--tool-help'","startedAt":"2012-03-17T02:00:13Z","lastAt":"2012-03-17T02:00:13Z","messageCount":1,"participants":["Tim Henigan"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"187125","messageId":"1331949613-15284-1-git-send-email-tim.henigan@gmail.com","threadId":"29971","inReplyTo":null,"subject":"[PATCH 9/9] difftool: print list of valid tools with '--tool-help'","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2012-03-17T02:00:13Z","receivedAt":"2012-03-17T02:00:13Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"Since bc7a96a (mergetool--lib: Refactor tools into separate files,\n2011-08-18), it is possible to add a new diff tool by creating a simple\nscript in the '$(git --exec-path)/mergetools' directory.  Updating the\ndifftool help text is still a manual process, and the documentation can\neasily go out of sync.\n\nTeach the command to read the list of valid tools from the 'mergetools'\ndirectory and print them for the user when the '--tool-help' option is\ngiven.\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n\nConflicts:\n\n\tgit-difftool.perl\n---\n Documentation/git-difftool.txt |   11 ++++++-----\n git-difftool.perl              |   17 ++++++++++++++---\n 2 files changed, 20 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt\nindex aba5e76..31fc2e3 100644\n--- a/Documentation/git-difftool.txt\n+++ b/Documentation/git-difftool.txt\n@@ -36,11 +36,9 @@ OPTIONS\n \n -t <tool>::\n --tool=<tool>::\n-\tUse the diff tool specified by <tool>.\n-\tValid diff tools are:\n-\taraxis, bc3, deltawalker, diffuse, emerge, ecmerge, gvimdiff,\n-\tkdiff3,\tkompare, meld, opendiff, p4merge, tkdiff, vimdiff and\n-\txxdiff.\n+\tUse the diff tool specified by <tool>.  Valid values include\n+\temerge, kompare, meld, and vimdiff. Run `git difftool --tool-help`\n+\tfor the list of valid <tool> settings.\n +\n If a diff tool is not specified, 'git difftool'\n will use the configuration variable `diff.tool`.  If the\n@@ -68,6 +66,9 @@ of the diff post-image.  `$MERGED` is the name of the file which is\n being compared. `$BASE` is provided for compatibility\n with custom merge tool commands and has the same value as `$MERGED`.\n \n+--tool-help::\n+\tPrint a list of diff tools that may be used with `--tool`.\n+\n -x <command>::\n --extcmd=<command>::\n \tSpecify a custom command for viewing diffs.\ndiff --git a/git-difftool.perl b/git-difftool.perl\nindex ebffd1e..c17266f 100755\n--- a/git-difftool.perl\n+++ b/git-difftool.perl\n@@ -14,7 +14,7 @@\n use 5.008;\n use strict;\n use warnings;\n-use File::Basename qw(dirname);\n+use File::Basename qw(dirname basename);\n use File::Copy;\n use File::stat;\n use File::Path qw(mkpath);\n@@ -28,7 +28,8 @@ sub usage\n {\n \tmy $exitcode = shift;\n \tprint << 'USAGE';\n-usage: git difftool [-t|--tool=<tool>] [-x|--extcmd=<cmd>]\n+usage: git difftool [-t|--tool=<tool>] [--tool-help]\n+                    [-x|--extcmd=<cmd>]\n                     [-y|--no-prompt]   [-g|--gui]\n                     [-d|--dir-diff]\n                     ['git diff' options]\n@@ -129,18 +130,28 @@ sub setup_dir_diff\n \n # parse command-line options. all unrecognized options and arguments\n # are passed through to the 'git diff' command.\n-my ($difftool_cmd, $dirdiff, $extcmd, $gui, $help, $no_prompt, $prompt);\n+my ($difftool_cmd, $dirdiff, $extcmd, $gui, $help, $no_prompt, $prompt, $tool_help);\n GetOptions('g|gui' => \\$gui,\n \t'd|dir-diff' => \\$dirdiff,\n \t'h' => \\$help,\n \t'prompt' => \\$prompt,\n \t't|tool:s' => \\$difftool_cmd,\n+\t'tool-help' => \\$tool_help,\n \t'x|extcmd:s' => \\$extcmd,\n \t'y|no-prompt' => \\$no_prompt);\n \n if (defined($help)) {\n \tusage(0);\n } \n+if (defined($tool_help)) {\n+\tmy $gitpath = Git::exec_path();\n+\tprint \"'git difftool --tool=<tool>' may be set to one of the following:\\n\";\n+\tfor (glob \"mergetools/*\") {\n+\t\tnext if /defaults$/;\n+\t\tprint \"\\t\" . basename($_) . \"\\n\";\n+\t}\n+\texit(0);\n+}\n if (defined($difftool_cmd)) {\n \tif (length($difftool_cmd) > 0) {\n \t\t$ENV{GIT_DIFF_TOOL} = $difftool_cmd;\n-- \n1.7.9.1.290.gbd444\n"}]}