summaryrefslogtreecommitdiff
path: root/git-difftool.perl
diff options
context:
space:
mode:
authorTim Henigan <tim.henigan@gmail.com>2012-03-15 18:25:11 -0400
committerJunio C Hamano <gitster@pobox.com>2012-03-15 15:52:54 -0700
commit061e672692e9ed3deceeef2da308037e63384bb4 (patch)
tree73b06c3938713b10509ad17f6bd43fcca5002d83 /git-difftool.perl
parentbc7a96a8965d4ce0651689301e1702a942dfb9f0 (diff)
downloadgit-th/mergetools-tool-help.tar.gz
difftool: print list of valid tools with '--tool-help'th/mergetools-tool-help
Since bc7a96a (mergetool--lib: Refactor tools into separate files, 2011-08-18), it is possible to add a new diff tool by creating a simple script in the '$(git --exec-path)/mergetools' directory. Updating the difftool help text is still a manual process, and the documentation can easily go out of sync. Teach the command to read the list of valid tools from the 'mergetools' directory and print them for the user when the '--tool-help' option is given. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-difftool.perl')
-rwxr-xr-xgit-difftool.perl14
1 files changed, 12 insertions, 2 deletions
diff --git a/git-difftool.perl b/git-difftool.perl
index ced1615e21..ad777efa2b 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' || $arg eq '--help') {
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') {