Since bc7a96a, it is possible to add new diff tools by creating a simple script file in the '$(git --exec-path)/mergetools' directory. However, updating the difftool help text is still a manual process. This commit reads the list of valid diff tools from the 'mergetools' directory and prints them for the user when the '--tool-help' option is given. Signed-off-by: Tim Henigan <tim.henigan@xxxxxxxxx> --- Documentation/git-difftool.txt | 7 ++++--- git-difftool.perl | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt index 19d473c..2b4b6ee 100644 --- a/Documentation/git-difftool.txt +++ b/Documentation/git-difftool.txt @@ -31,9 +31,10 @@ OPTIONS -t <tool>:: --tool=<tool>:: Use the diff tool specified by <tool>. - Valid diff tools are: - araxis, bc3, diffuse, emerge, ecmerge, gvimdiff, kdiff3, - kompare, meld, opendiff, p4merge, tkdiff, vimdiff and xxdiff. + See `--tool-help` for the list of valid <tool> settings. + +--tool-help:: + Print a list of diff tools that may be used with `--tool`. + If a diff tool is not specified, 'git difftool' will use the configuration variable `diff.tool`. If the diff --git a/git-difftool.perl b/git-difftool.perl index 09b65f1..4cfb1ae 100755 --- a/git-difftool.perl +++ b/git-difftool.perl @@ -14,7 +14,7 @@ use 5.008; use strict; use warnings; use Cwd qw(abs_path); -use File::Basename qw(dirname); +use File::Basename qw(dirname basename); require Git; @@ -24,7 +24,8 @@ my $DIR = abs_path(dirname($0)); sub usage { print << 'USAGE'; -usage: git difftool [-t|--tool=<tool>] [-x|--extcmd=<cmd>] +usage: git difftool [-t|--tool=<tool>] [--tool-help] + [-x|--extcmd=<cmd>] [-y|--no-prompt] [-g|--gui] ['git diff' options] USAGE @@ -100,6 +101,15 @@ sub generate_command if ($arg eq '-h') { usage(); } + if ($arg eq '--tool-help') { + my $gitpath = Git::exec_path(); + print "'git difftool --tool=<tool>' may be set to one of the following:\n"; + for (glob "$gitpath/mergetools/*") { + next if /defaults$/; + print "\t" . basename($_) . "\n"; + } + exit(1); + } push @command, $arg; } if ($prompt eq 'yes') { -- 1.7.9.GIT -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html