difftool: rename variables for consistency

Always call the list of files @files. Always call the worktree $worktree. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

David Aguilar committed Dec 9, 2016 at 00:58 UTC ce6926974ec7b28ad43c387d5aa8ae7ea9f72e65
1 file changed +14 -14
git-difftool.perl
+14 -14
@@ -100,7 +100,7 @@ sub changed_files
100
101 sub setup_dir_diff
102 {
103 - my ($workdir, $symlinks) = @_;
103 + my ($worktree, $symlinks) = @_;
104 my @gitargs = ('diff', '--raw', '--no-abbrev', '-z', @ARGV);
105 my $diffrtn = Git::command_oneline(@gitargs);
106 exit(0) unless defined($diffrtn);
@@ -109,7 +109,7 @@ sub setup_dir_diff
109 # changed files. The paths returned by diff --raw are relative to the
110 # top-level of the repository, but we defer changing directories so
111 # that @ARGV can perform pathspec limiting in the current directory.
112 - chdir($workdir);
112 + chdir($worktree);
113
114 # Build index info for left and right sides of the diff
115 my $submodule_mode = '160000';
@@ -121,7 +121,7 @@ sub setup_dir_diff
121 my $wtindex = '';
122 my %submodule;
123 my %symlink;
124 - my @working_tree = ();
124 + my @files = ();
125 my %working_tree_dups = ();
126 my @rawdiff = split('\0', $diffrtn);
127
@@ -173,14 +173,14 @@ EOF
173 }
174
175 if ($rmode ne $null_mode) {
176 - # Avoid duplicate working_tree entries
176 + # Avoid duplicate entries
177 if ($working_tree_dups{$dst_path}++) {
178 next;
179 }
180 my ($use, $wt_sha1) =
181 use_wt_file($dst_path, $rsha1);
182 if ($use) {
183 - push @working_tree, $dst_path;
183 + push @files, $dst_path;
184 $wtindex .= "$rmode $wt_sha1\t$dst_path\0";
185 } else {
186 $rindex .= "$rmode $rsha1\t$dst_path\0";
@@ -227,14 +227,14 @@ EOF
227
228 # Changes in the working tree need special treatment since they are
229 # not part of the index.
230 - for my $file (@working_tree) {
230 + for my $file (@files) {
231 my $dir = dirname($file);
232 unless (-d "$rdir/$dir") {
233 mkpath("$rdir/$dir") or
234 exit_cleanup($tmpdir, 1);
235 }
236 if ($symlinks) {
237 - symlink("$workdir/$file", "$rdir/$file") or
237 + symlink("$worktree/$file", "$rdir/$file") or
238 exit_cleanup($tmpdir, 1);
239 } else {
240 copy($file, "$rdir/$file") or
@@ -278,7 +278,7 @@ EOF
278 exit_cleanup($tmpdir, 1) if not $ok;
279 }
280
281 - return ($ldir, $rdir, $tmpdir, @working_tree);
281 + return ($ldir, $rdir, $tmpdir, @files);
282 }
283
284 sub write_to_file
@@ -388,9 +388,9 @@ sub dir_diff
388 my $error = 0;
389 my $repo = Git->repository();
390 my $repo_path = $repo->repo_path();
391 - my $workdir = $repo->wc_path();
392 - $workdir =~ s|/$||; # Avoid double slashes in symlink targets
393 - my ($a, $b, $tmpdir, @worktree) = setup_dir_diff($workdir, $symlinks);
391 + my $worktree = $repo->wc_path();
392 + $worktree =~ s|/$||; # Avoid double slashes in symlink targets
393 + my ($a, $b, $tmpdir, @files) = setup_dir_diff($worktree, $symlinks);
394
395 if (defined($extcmd)) {
396 $rc = system($extcmd, $a, $b);
@@ -411,13 +411,13 @@ sub dir_diff
411 my %tmp_modified;
412 my $indices_loaded = 0;
413
414 - for my $file (@worktree) {
414 + for my $file (@files) {
415 next if $symlinks && -l "$b/$file";
416 next if ! -f "$b/$file";
417
418 if (!$indices_loaded) {
419 %wt_modified = changed_files(
420 - $repo_path, "$tmpdir/wtindex", $workdir);
420 + $repo_path, "$tmpdir/wtindex", $worktree);
421 %tmp_modified = changed_files(
422 $repo_path, "$tmpdir/wtindex", $b);
423 $indices_loaded = 1;
@@ -425,7 +425,7 @@ sub dir_diff
425
426 if (exists $wt_modified{$file} and exists $tmp_modified{$file}) {
427 my $errmsg = "warning: Both files modified: ";
428 - $errmsg .= "'$workdir/$file' and '$b/$file'.\n";
428 + $errmsg .= "'$worktree/$file' and '$b/$file'.\n";
429 $errmsg .= "warning: Working tree file has been left.\n";
430 $errmsg .= "warning:\n";
431 warn $errmsg;