From: David Aguilar <davvid@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, John Keeping <john@keeping.me.uk>
Subject: [PATCH 4/7] git-difftool: use git-mergetool--lib for "--tool-help"
Date: Fri, 25 Jan 2013 01:43:51 -0800 [thread overview]
Message-ID: <1359107034-14606-5-git-send-email-davvid@gmail.com> (raw)
In-Reply-To: <1359107034-14606-1-git-send-email-davvid@gmail.com>
From: John Keeping <john@keeping.me.uk>
The "--tool-help" option to git-difftool currently displays incorrect
output since it uses the names of the files in
"$GIT_EXEC_PATH/mergetools/" rather than the list of command names in
git-mergetool--lib.
Fix this by simply delegating the "--tool-help" argument to the
show_tool_help function in git-mergetool--lib.
Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-difftool.perl | 55 +++++++------------------------------------------------
1 file changed, 7 insertions(+), 48 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index edd0493..0a90de4 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -59,57 +59,16 @@ sub find_worktree
return $worktree;
}
-sub filter_tool_scripts
-{
- my ($tools) = @_;
- if (-d $_) {
- if ($_ ne ".") {
- # Ignore files in subdirectories
- $File::Find::prune = 1;
- }
- } else {
- if ((-f $_) && ($_ ne "defaults")) {
- push(@$tools, $_);
- }
- }
-}
-
sub print_tool_help
{
- my ($cmd, @found, @notfound, @tools);
- my $gitpath = Git::exec_path();
-
- find(sub { filter_tool_scripts(\@tools) }, "$gitpath/mergetools");
-
- foreach my $tool (@tools) {
- $cmd = "TOOL_MODE=diff";
- $cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"';
- $cmd .= " && get_merge_tool_path $tool >/dev/null 2>&1";
- $cmd .= " && can_diff >/dev/null 2>&1";
- if (system('sh', '-c', $cmd) == 0) {
- push(@found, $tool);
- } else {
- push(@notfound, $tool);
- }
- }
-
- print << 'EOF';
-'git difftool --tool=<tool>' may be set to one of the following:
-EOF
- print "\t$_\n" for (sort(@found));
+ my $cmd = 'TOOL_MODE=diff';
+ $cmd .= ' && . "$(git --exec-path)/git-mergetool--lib"';
+ $cmd .= ' && show_tool_help';
- print << 'EOF';
-
-The following tools are valid, but not currently available:
-EOF
- print "\t$_\n" for (sort(@notfound));
-
- print << 'EOF';
-
-NOTE: Some of the tools listed above only work in a windowed
-environment. If run in a terminal-only session, they will fail.
-EOF
- exit(0);
+ # See the comment at the bottom of file_diff() for the reason behind
+ # using system() followed by exit() instead of exec().
+ my $rc = system('sh', '-c', $cmd);
+ exit($rc | ($rc >> 8));
}
sub exit_cleanup
--
1.8.1.1.367.g22b1720.dirty
next prev parent reply other threads:[~2013-01-25 9:45 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-25 9:43 [PATCH 0/7] mergetool-lib improvements for --tool-help David Aguilar
2013-01-25 9:43 ` [PATCH 1/7] git-mergetool: move show_tool_help to mergetool--lib David Aguilar
2013-01-25 9:43 ` [PATCH 2/7] git-mergetool: remove redundant assignment David Aguilar
2013-01-25 9:43 ` [PATCH 3/7] git-mergetool: don't hardcode 'mergetool' in show_tool_help David Aguilar
2013-01-25 9:43 ` David Aguilar [this message]
2013-01-25 9:43 ` [PATCH 5/7] mergetools/vim: Remove redundant diff command David Aguilar
2013-01-25 9:43 ` [PATCH 6/7] mergetools: Fix difftool/mergetool --tool-help listing for vim David Aguilar
2013-01-25 10:23 ` Sebastian Schuberth
2013-01-25 10:28 ` David Aguilar
2013-01-25 10:34 ` Sebastian Schuberth
2013-01-25 11:39 ` Sebastian Schuberth
2013-01-25 10:38 ` John Keeping
2013-01-25 10:40 ` David Aguilar
2013-01-25 19:11 ` Junio C Hamano
2013-01-25 9:43 ` [PATCH 7/7] mergetool--lib: Improve show_tool_help() output David Aguilar
2013-01-25 19:54 ` John Keeping
2013-01-25 20:06 ` Junio C Hamano
2013-01-25 20:08 ` John Keeping
2013-01-25 20:16 ` Junio C Hamano
2013-01-25 20:46 ` John Keeping
2013-01-25 20:56 ` Junio C Hamano
2013-01-25 21:16 ` John Keeping
2013-01-25 21:47 ` Junio C Hamano
2013-01-25 22:02 ` John Keeping
2013-01-25 22:03 ` [PATCH 8/7] mergetool--lib: don't call "exit" in setup_tool John Keeping
2013-01-26 0:24 ` Junio C Hamano
2013-01-26 7:01 ` David Aguilar
2013-01-26 12:17 ` [PATCH 1/2 v2] " John Keeping
2013-01-26 13:50 ` [PATCH 1/2 v3] " John Keeping
2013-01-25 22:04 ` [PATCH 9/7] mergetool--lib: fix path lookup in guess_merge_tool John Keeping
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=1359107034-14606-5-git-send-email-davvid@gmail.com \
--to=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=john@keeping.me.uk \
/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).