git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] difftool: Simplify print_tool_help()
@ 2012-07-23  3:42 David Aguilar
  2012-07-23  3:42 ` [PATCH 2/5] difftool: Eliminate global variables David Aguilar
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: David Aguilar @ 2012-07-23  3:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Tim Henigan, git

Eliminate a global variable and File::Find usage by building upon
basename() and glob() instead.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2 0/5] difftool: Use symlinks in dir-diff mode
@ 2012-07-23  3:57 David Aguilar
  2012-07-23  3:57 ` [PATCH v2 1/5] difftool: Simplify print_tool_help() David Aguilar
  0 siblings, 1 reply; 16+ messages in thread
From: David Aguilar @ 2012-07-23  3:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Tim Henigan, git

Teach the difftool script to use symlinks when doing
directory diffs in --dir-diff mode.

This is v2 of the patch because I had a typo in one of the
commit messages and gmail ate 4/5 in the last round.

David Aguilar (5):
  difftool: Simplify print_tool_help()
  difftool: Eliminate global variables
  difftool: Move option values into a hash
  difftool: Call the temp directory "git-difftool"
  difftool: Use symlinks when diffing against the worktree

 Documentation/git-difftool.txt |   8 ++
 git-difftool.perl              | 184 ++++++++++++++++++++++++-----------------
 2 files changed, 115 insertions(+), 77 deletions(-)

-- 
1.7.11.2.255.g5f133da

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

end of thread, other threads:[~2012-07-25  3:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-23  3:42 [PATCH 1/5] difftool: Simplify print_tool_help() David Aguilar
2012-07-23  3:42 ` [PATCH 2/5] difftool: Eliminate global variables David Aguilar
2012-07-23  6:13   ` Sebastian Schuberth
2012-07-23  6:21     ` David Aguilar
2012-07-23  6:30       ` Sebastian Schuberth
2012-07-23  6:44         ` David Aguilar
2012-07-23  6:54           ` Sebastian Schuberth
2012-07-23  3:42 ` [PATCH 3/5] difftool: Move option values into a hash David Aguilar
2012-07-23  3:49   ` David Aguilar
2012-07-23  3:42 ` [PATCH 5/5] difftool: Use symlinks when diffing against the worktree David Aguilar
2012-07-24 12:43 ` [PATCH 1/5] difftool: Simplify print_tool_help() Tim Henigan
2012-07-25  1:52   ` David Aguilar
2012-07-25  2:18     ` David Aguilar
2012-07-25  2:40       ` Junio C Hamano
2012-07-25  3:00         ` David Aguilar
  -- strict thread matches above, loose matches on Subject: below --
2012-07-23  3:57 [PATCH v2 0/5] difftool: Use symlinks in dir-diff mode David Aguilar
2012-07-23  3:57 ` [PATCH v2 1/5] difftool: Simplify print_tool_help() David Aguilar
2012-07-23  3:57   ` [PATCH 2/5] difftool: Eliminate global variables David Aguilar

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).