Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Aguilar <davvid@gmail.com>2012-07-25 07:14:22 +0400
committerJunio C Hamano <gitster@pobox.com>2012-07-25 20:34:04 +0400
commit7c7584b97096a168fe1236c84e5e12d7bee24476 (patch)
tree173527e44215fd2b434a48d1508f846f52e7fc02 /git-difftool.perl
parent1f2293457579a5bf22bb9c8324ded22b10705cc2 (diff)
difftool: Handle finding mergetools/ in a path with spaces
Use the original File::Find implementation from bf73fc2 (difftool: print list of valid tools with '--tool-help', 2012-03-29) so that we properly handle mergetools/ being located in a path containing spaces. One small difference is that we avoid using a global variable by passing a reference to the list of tools. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-difftool.perl')
-rwxr-xr-xgit-difftool.perl27
1 files changed, 21 insertions, 6 deletions
diff --git a/git-difftool.perl b/git-difftool.perl
index a5b371f729..30574801be 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -13,9 +13,10 @@
use 5.008;
use strict;
use warnings;
-use File::Basename qw(basename dirname);
+use File::Basename qw(dirname);
use File::Copy;
use File::Compare;
+use File::Find;
use File::stat;
use File::Path qw(mkpath);
use File::Temp qw(tempdir);
@@ -58,13 +59,27 @@ 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);
+ my ($cmd, @found, @notfound, @tools);
my $gitpath = Git::exec_path();
- my @files = map { basename($_) } glob("$gitpath/mergetools/*");
- my @tools = sort(grep { !m{^defaults$} } @files);
+ find(sub { filter_tool_scripts(\@tools) }, "$gitpath/mergetools");
foreach my $tool (@tools) {
$cmd = "TOOL_MODE=diff";
@@ -79,10 +94,10 @@ sub print_tool_help
}
print "'git difftool --tool=<tool>' may be set to one of the following:\n";
- print "\t$_\n" for (@found);
+ print "\t$_\n" for (sort(@found));
print "\nThe following tools are valid, but not currently available:\n";
- print "\t$_\n" for (@notfound);
+ print "\t$_\n" for (sort(@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";