All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] difftool: print list of valid tools with '--tool-help'
@ 2012-03-15 22:25 Tim Henigan
  2012-03-15 22:32 ` Junio C Hamano
  2012-03-15 23:18 ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Tim Henigan @ 2012-03-15 22:25 UTC (permalink / raw)
  To: git, gitster; +Cc: Tim Henigan

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@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-03-26 16:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-15 22:25 [PATCH] difftool: print list of valid tools with '--tool-help' Tim Henigan
2012-03-15 22:32 ` Junio C Hamano
2012-03-17  3:31   ` David Aguilar
2012-03-15 23:18 ` Junio C Hamano
2012-03-23 18:26   ` Tim Henigan
2012-03-23 19:48     ` Junio C Hamano
2012-03-26 16:23       ` [PATCH 9/9 v7] " Tim Henigan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.