git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tim Henigan <tim.henigan@gmail.com>
To: git@vger.kernel.org, gitster@pobox.com
Cc: Tim Henigan <tim.henigan@gmail.com>
Subject: [PATCH] difftool: print list of valid tools with '--tool-help'
Date: Thu, 15 Mar 2012 18:25:11 -0400	[thread overview]
Message-ID: <1331850311-4620-1-git-send-email-tim.henigan@gmail.com> (raw)

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

             reply	other threads:[~2012-03-15 22:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-15 22:25 Tim Henigan [this message]
2012-03-15 22:32 ` [PATCH] difftool: print list of valid tools with '--tool-help' 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1331850311-4620-1-git-send-email-tim.henigan@gmail.com \
    --to=tim.henigan@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).