difftool: Simplify print_tool_help()
Eliminate a global variable and File::Find usage by building upon basename() and glob() instead. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
05df532655
commit
35989c68ee
|
@ -13,17 +13,15 @@
|
||||||
use 5.008;
|
use 5.008;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use File::Basename qw(dirname);
|
use File::Basename qw(basename dirname);
|
||||||
use File::Copy;
|
use File::Copy;
|
||||||
use File::Compare;
|
use File::Compare;
|
||||||
use File::Find;
|
|
||||||
use File::stat;
|
use File::stat;
|
||||||
use File::Path qw(mkpath);
|
use File::Path qw(mkpath);
|
||||||
use File::Temp qw(tempdir);
|
use File::Temp qw(tempdir);
|
||||||
use Getopt::Long qw(:config pass_through);
|
use Getopt::Long qw(:config pass_through);
|
||||||
use Git;
|
use Git;
|
||||||
|
|
||||||
my @tools;
|
|
||||||
my @working_tree;
|
my @working_tree;
|
||||||
my $rc;
|
my $rc;
|
||||||
my $repo = Git->repository();
|
my $repo = Git->repository();
|
||||||
|
@ -65,26 +63,13 @@ sub find_worktree
|
||||||
|
|
||||||
my $workdir = 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
|
sub print_tool_help
|
||||||
{
|
{
|
||||||
my ($cmd, @found, @notfound);
|
my ($cmd, @found, @notfound);
|
||||||
my $gitpath = Git::exec_path();
|
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) {
|
foreach my $tool (@tools) {
|
||||||
$cmd = "TOOL_MODE=diff";
|
$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 "'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 "\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 "\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";
|
print "environment. If run in a terminal-only session, they will fail.\n";
|
||||||
|
|
Loading…
Reference in New Issue