Thread (6 messages) flat view 6 messages, 1 author, 2016-06-15
DORMANTno replies

Revision v4 of 2 in this series.

Revisions (2)
  1. v2 [diff vs current]
  2. v4 current

[PATCH v4 1/5] difftool: print_tool_help() globals

From: David Aguilar <hidden>
Date: 2016-06-15 22:54:19
Subsystem: the rest · Maintainer: Linus Torvalds

Replace a global variable with a closure.

Signed-off-by: David Aguilar <redacted>
---
Differences from last time:

This keeps the original File::Find implementation and wraps the
global variable in a closure as the first step in the
globals-elimination cleanup.

 git-difftool.perl | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index c079854..d4737e1 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -23,7 +23,6 @@ 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();
@@ -67,6 +66,7 @@ my $workdir = find_worktree();
 
 sub filter_tool_scripts
 {
+	my ($tools) = @_;
 	if (-d $_) {
 		if ($_ ne ".") {
 			# Ignore files in subdirectories
@@ -74,17 +74,17 @@ sub filter_tool_scripts
 		}
 	} else {
 		if ((-f $_) && ($_ ne "defaults")) {
-			push(@tools, $_);
+			push(@$tools, $_);
 		}
 	}
 }
 
 sub print_tool_help
 {
-	my ($cmd, @found, @notfound);
+	my ($cmd, @found, @notfound, @tools);
 	my $gitpath = Git::exec_path();
 
-	find(\&filter_tool_scripts, "$gitpath/mergetools");
+	find(sub { filter_tool_scripts(\@tools) }, "$gitpath/mergetools");
 
 	foreach my $tool (@tools) {
 		$cmd  = "TOOL_MODE=diff";
-- 
1.7.12.rc0.15.g8157c39
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help