From: David Aguilar <davvid@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Tim Henigan <tim.henigan@gmail.com>, git@vger.kernel.org
Subject: [PATCH v2 1/5] difftool: Simplify print_tool_help()
Date: Sun, 22 Jul 2012 20:57:07 -0700 [thread overview]
Message-ID: <1343015831-17498-2-git-send-email-davvid@gmail.com> (raw)
In-Reply-To: <1343015831-17498-1-git-send-email-davvid@gmail.com>
Eliminate a global variable and File::Find usage by building upon
basename() and glob() instead.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
Same as before, resending because gmail ate patch 4/5
git-difftool.perl | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index c079854..ac0ed63 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -13,17 +13,15 @@
use 5.008;
use strict;
use warnings;
-use File::Basename qw(dirname);
+use File::Basename qw(basename dirname);
use File::Copy;
use File::Compare;
-use File::Find;
use File::stat;
use File::Path qw(mkpath);
use File::Temp qw(tempdir);
use Getopt::Long qw(:config pass_through);
use Git;
-my @tools;
my @working_tree;
my $rc;
my $repo = Git->repository();
@@ -65,26 +63,13 @@ sub find_worktree
my $workdir = find_worktree();
-sub filter_tool_scripts
-{
- 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);
my $gitpath = Git::exec_path();
- find(\&filter_tool_scripts, "$gitpath/mergetools");
+ my @files = map { basename($_) } glob("$gitpath/mergetools/*");
+ my @tools = sort(grep { !m{^defaults$} } @files);
foreach my $tool (@tools) {
$cmd = "TOOL_MODE=diff";
@@ -99,10 +84,10 @@ sub print_tool_help
}
print "'git difftool --tool=<tool>' may be set to one of the following:\n";
- print "\t$_\n" for (sort(@found));
+ print "\t$_\n" for (@found);
print "\nThe following tools are valid, but not currently available:\n";
- print "\t$_\n" for (sort(@notfound));
+ print "\t$_\n" for (@notfound);
print "\nNOTE: Some of the tools listed above only work in a windowed\n";
print "environment. If run in a terminal-only session, they will fail.\n";
--
1.7.11.2.255.g5f133da
next prev parent reply other threads:[~2012-07-23 3:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-23 3:57 [PATCH v2 0/5] difftool: Use symlinks in dir-diff mode David Aguilar
2012-07-23 3:57 ` David Aguilar [this message]
2012-07-23 3:57 ` [PATCH 2/5] difftool: Eliminate global variables David Aguilar
2012-07-23 3:57 ` [PATCH 3/5] difftool: Move option values into a hash David Aguilar
2012-07-23 3:57 ` [PATCH 4/5] difftool: Call the temp directory "git-difftool" David Aguilar
2012-07-23 3:57 ` [PATCH 5/5] difftool: Use symlinks when diffing against the worktree David Aguilar
2012-07-23 4:57 ` Junio C Hamano
2012-07-23 6:05 ` [PATCH v3 4/5] " David Aguilar
2012-07-23 16:38 ` Junio C Hamano
2012-07-24 13:35 ` Tim Henigan
2012-07-24 15:57 ` Junio C Hamano
2012-07-23 5:14 ` [PATCH v2 0/5] difftool: Use symlinks in dir-diff mode Junio C Hamano
2012-07-23 5:34 ` David Aguilar
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=1343015831-17498-2-git-send-email-davvid@gmail.com \
--to=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=tim.henigan@gmail.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).