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: gracefully handle symlinks to directories
Date: Wed, 21 Oct 2015 01:04:33 -0700 [thread overview]
Message-ID: <1445414673-15307-1-git-send-email-davvid@gmail.com> (raw)
difftool's dir-diff feature was blindly feeding worktree paths
to hash-object without checking whether the path was indeed a
file, causing the feature to fail when repositories contain
symlinks to directories.
Ensure that only files are ever given to hash-object.
Add a test to demonstrate the breakage.
Reported-by: Ismail Badawi <ismail@badawi.io>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
git-difftool.perl | 4 +---
t/t7800-difftool.sh | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/git-difftool.perl b/git-difftool.perl
index 7df7c8a..1abe647 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -70,9 +70,7 @@ sub use_wt_file
my ($repo, $workdir, $file, $sha1) = @_;
my $null_sha1 = '0' x 40;
- if (! -e "$workdir/$file") {
- # If the file doesn't exist in the working tree, we cannot
- # use it.
+ if (! -f "$workdir/$file") {
return (0, $null_sha1);
}
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 48c6e2b..ec8bc8c 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -504,4 +504,23 @@ test_expect_success PERL 'difftool properly honors gitlink and core.worktree' '
)
'
+test_expect_success PERL,SYMLINKS 'difftool --dir-diff symlinked directories' '
+ git init dirlinks &&
+ (
+ cd dirlinks &&
+ git config diff.tool checktrees &&
+ git config difftool.checktrees.cmd "echo good" &&
+ mkdir foo &&
+ : >foo/bar &&
+ git add foo/bar &&
+ test_commit symlink-one &&
+ ln -s foo link &&
+ git add link &&
+ test_commit symlink-two &&
+ echo good >expect &&
+ git difftool --tool=checktrees --dir-diff HEAD~ >actual &&
+ test_cmp expect actual
+ )
+'
+
test_done
--
2.6.2.281.gac28444
next reply other threads:[~2015-10-21 8:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-21 8:04 David Aguilar [this message]
2015-10-22 18:23 ` [PATCH] difftool: gracefully handle symlinks to directories Junio C Hamano
2015-10-27 21:30 ` David Aguilar
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=1445414673-15307-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).