From: David Aguilar <davvid@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git ML <git@vger.kernel.org>
Subject: [PATCH 3/3] difftool: rename variables for consistency
Date: Fri, 9 Dec 2016 00:58:48 -0800 [thread overview]
Message-ID: <20161209085848.10929-3-davvid@gmail.com> (raw)
In-Reply-To: <20161209085848.10929-1-davvid@gmail.com>
Always call the list of files @files.
Always call the worktree $worktree.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
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.0.26.gb65c994
prev parent reply other threads:[~2016-12-09 8:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-09 8:58 [PATCH 1/3] difftool: sanitize $workdir as early as possible David Aguilar
2016-12-09 8:58 ` [PATCH 2/3] difftool: chdir " David Aguilar
2016-12-09 23:02 ` Junio C Hamano
2016-12-10 0:03 ` David Aguilar
2016-12-09 8:58 ` David Aguilar [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161209085848.10929-3-davvid@gmail.com \
--to=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.