From: David Aguilar <davvid@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Ismail Badawi <ismail@badawi.io>,
John Keeping <john@keeping.me.uk>,
Tim Henigan <tim.henigan@gmail.com>,
Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] difftool: avoid symlinks when reusing worktree files
Date: Tue, 27 Oct 2015 14:24:48 -0700 [thread overview]
Message-ID: <1445981088-6285-1-git-send-email-davvid@gmail.com> (raw)
difftool's dir-diff should never reuse a symlink, regardless of
what it points to. Tighten use_wt_file() so that it rejects all
symlinks.
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-difftool.perl | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index 1abe647..873db57 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -70,13 +70,13 @@ sub use_wt_file
my ($repo, $workdir, $file, $sha1) = @_;
my $null_sha1 = '0' x 40;
- if (! -f "$workdir/$file") {
- return (0, $null_sha1);
+ my $workfile = "$workdir/$file";
+ if (-f $workfile && ! -l $workfile) {
+ my $wt_sha1 = $repo->command_oneline('hash-object', $workfile);
+ my $use = ($sha1 eq $null_sha1) || ($sha1 eq $wt_sha1);
+ return ($use, $wt_sha1);
}
-
- my $wt_sha1 = $repo->command_oneline('hash-object', "$workdir/$file");
- my $use = ($sha1 eq $null_sha1) || ($sha1 eq $wt_sha1);
- return ($use, $wt_sha1);
+ return (0, $null_sha1);
}
sub changed_files
--
2.6.2.282.gfefd36e
next reply other threads:[~2015-10-27 21:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-27 21:24 David Aguilar [this message]
2015-10-27 22:24 ` [PATCH] difftool: avoid symlinks when reusing worktree files Junio C Hamano
2015-10-29 1:55 ` David Aguilar
2015-10-29 17:59 ` Junio C Hamano
2015-10-29 18:19 ` Junio C Hamano
2015-10-30 7:28 ` David Aguilar
2015-10-30 16:19 ` Junio C Hamano
2015-10-27 22:41 ` Junio C Hamano
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=1445981088-6285-1-git-send-email-davvid@gmail.com \
--to=davvid@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=ismail@badawi.io \
--cc=john@keeping.me.uk \
--cc=tim.henigan@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).