Skip to content

Commit aa0b4c3

Browse files
committed
Merge branch 'da/difftool' into maint
The code to prepare the working tree side of temporary directory for the "dir-diff" feature forgot that symbolic links need not be copied (or symlinked) to the temporary area, as the code already special cases and overwrites them. Besides, it was wrong to try computing the object name of the target of symbolic link, which may not even exist or may be a directory. * da/difftool: difftool: ignore symbolic links in use_wt_file
2 parents b50ceab + cfe2d4b commit aa0b4c3

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

git-difftool.perl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ sub use_wt_file
7070
my ($repo, $workdir, $file, $sha1) = @_;
7171
my $null_sha1 = '0' x 40;
7272

73-
if (! -e "$workdir/$file") {
74-
# If the file doesn't exist in the working tree, we cannot
75-
# use it.
73+
if (-l "$workdir/$file" || ! -e _) {
7674
return (0, $null_sha1);
7775
}
7876

t/t7800-difftool.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,4 +504,23 @@ test_expect_success PERL 'difftool properly honors gitlink and core.worktree' '
504504
)
505505
'
506506

507+
test_expect_success PERL,SYMLINKS 'difftool --dir-diff symlinked directories' '
508+
git init dirlinks &&
509+
(
510+
cd dirlinks &&
511+
git config diff.tool checktrees &&
512+
git config difftool.checktrees.cmd "echo good" &&
513+
mkdir foo &&
514+
: >foo/bar &&
515+
git add foo/bar &&
516+
test_commit symlink-one &&
517+
ln -s foo link &&
518+
git add link &&
519+
test_commit symlink-two &&
520+
echo good >expect &&
521+
git difftool --tool=checktrees --dir-diff HEAD~ >actual &&
522+
test_cmp expect actual
523+
)
524+
'
525+
507526
test_done

0 commit comments

Comments
 (0)