From ce6926974ec7b28ad43c387d5aa8ae7ea9f72e65 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Fri, 9 Dec 2016 00:58:48 -0800 Subject: [PATCH] difftool: rename variables for consistency Always call the list of files @files. Always call the worktree $worktree. Signed-off-by: David Aguilar Signed-off-by: Junio C Hamano --- git-difftool.perl | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/git-difftool.perl b/git-difftool.perl index 99b03949bf..4e4f5d8138 100755 --- a/git-difftool.perl +++ b/git-difftool.perl @@ -100,7 +100,7 @@ sub changed_files sub setup_dir_diff { - my ($workdir, $symlinks) = @_; + my ($worktree, $symlinks) = @_; my @gitargs = ('diff', '--raw', '--no-abbrev', '-z', @ARGV); my $diffrtn = Git::command_oneline(@gitargs); exit(0) unless defined($diffrtn); @@ -109,7 +109,7 @@ sub setup_dir_diff # changed files. The paths returned by diff --raw are relative to the # top-level of the repository, but we defer changing directories so # that @ARGV can perform pathspec limiting in the current directory. - chdir($workdir); + chdir($worktree); # Build index info for left and right sides of the diff my $submodule_mode = '160000'; @@ -121,7 +121,7 @@ sub setup_dir_diff my $wtindex = ''; my %submodule; my %symlink; - my @working_tree = (); + my @files = (); my %working_tree_dups = (); my @rawdiff = split('\0', $diffrtn); @@ -173,14 +173,14 @@ EOF } if ($rmode ne $null_mode) { - # Avoid duplicate working_tree entries + # Avoid duplicate entries if ($working_tree_dups{$dst_path}++) { next; } my ($use, $wt_sha1) = use_wt_file($dst_path, $rsha1); if ($use) { - push @working_tree, $dst_path; + push @files, $dst_path; $wtindex .= "$rmode $wt_sha1\t$dst_path\0"; } else { $rindex .= "$rmode $rsha1\t$dst_path\0"; @@ -227,14 +227,14 @@ EOF # Changes in the working tree need special treatment since they are # not part of the index. - for my $file (@working_tree) { + for my $file (@files) { my $dir = dirname($file); unless (-d "$rdir/$dir") { mkpath("$rdir/$dir") or exit_cleanup($tmpdir, 1); } if ($symlinks) { - symlink("$workdir/$file", "$rdir/$file") or + symlink("$worktree/$file", "$rdir/$file") or exit_cleanup($tmpdir, 1); } else { copy($file, "$rdir/$file") or @@ -278,7 +278,7 @@ EOF exit_cleanup($tmpdir, 1) if not $ok; } - return ($ldir, $rdir, $tmpdir, @working_tree); + return ($ldir, $rdir, $tmpdir, @files); } sub write_to_file @@ -388,9 +388,9 @@ sub dir_diff my $error = 0; my $repo = Git->repository(); my $repo_path = $repo->repo_path(); - my $workdir = $repo->wc_path(); - $workdir =~ s|/$||; # Avoid double slashes in symlink targets - my ($a, $b, $tmpdir, @worktree) = setup_dir_diff($workdir, $symlinks); + my $worktree = $repo->wc_path(); + $worktree =~ s|/$||; # Avoid double slashes in symlink targets + my ($a, $b, $tmpdir, @files) = setup_dir_diff($worktree, $symlinks); if (defined($extcmd)) { $rc = system($extcmd, $a, $b); @@ -411,13 +411,13 @@ sub dir_diff my %tmp_modified; my $indices_loaded = 0; - for my $file (@worktree) { + for my $file (@files) { next if $symlinks && -l "$b/$file"; next if ! -f "$b/$file"; if (!$indices_loaded) { %wt_modified = changed_files( - $repo_path, "$tmpdir/wtindex", $workdir); + $repo_path, "$tmpdir/wtindex", $worktree); %tmp_modified = changed_files( $repo_path, "$tmpdir/wtindex", $b); $indices_loaded = 1; @@ -425,7 +425,7 @@ sub dir_diff if (exists $wt_modified{$file} and exists $tmp_modified{$file}) { my $errmsg = "warning: Both files modified: "; - $errmsg .= "'$workdir/$file' and '$b/$file'.\n"; + $errmsg .= "'$worktree/$file' and '$b/$file'.\n"; $errmsg .= "warning: Working tree file has been left.\n"; $errmsg .= "warning:\n"; warn $errmsg; -- 2.11.4.GIT