Skip to content
This repository was archived by the owner on Jul 2, 2019. It is now read-only.

Commit 2fc0c02

Browse files
committed
Merge branch 'ks/difftool-dir-diff-copy-fix'
"difftool --dir-diff" did not copy back changes made by the end-user in the diff tool backend to the working tree in some cases. * ks/difftool-dir-diff-copy-fix: difftool --dir-diff: allow changing any clean working tree file
2 parents 5adb374 + 32eaf1d commit 2fc0c02

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

git-difftool.perl

+2-7
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,9 @@ sub exit_cleanup
8585

8686
sub use_wt_file
8787
{
88-
my ($repo, $workdir, $file, $sha1, $symlinks) = @_;
88+
my ($repo, $workdir, $file, $sha1) = @_;
8989
my $null_sha1 = '0' x 40;
9090

91-
if ($sha1 ne $null_sha1 and not $symlinks) {
92-
return 0;
93-
}
94-
9591
if (! -e "$workdir/$file") {
9692
# If the file doesn't exist in the working tree, we cannot
9793
# use it.
@@ -213,8 +209,7 @@ sub setup_dir_diff
213209

214210
if ($rmode ne $null_mode) {
215211
my ($use, $wt_sha1) = use_wt_file($repo, $workdir,
216-
$dst_path, $rsha1,
217-
$symlinks);
212+
$dst_path, $rsha1);
218213
if ($use) {
219214
push @working_tree, $dst_path;
220215
$wtindex .= "$rmode $wt_sha1\t$dst_path\0";

t/t7800-difftool.sh

+19
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,25 @@ test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstage
385385
test_cmp actual expect
386386
'
387387

388+
write_script modify-right-file <<\EOF
389+
echo "new content" >"$2/file"
390+
EOF
391+
392+
run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' '
393+
test_when_finished git reset --hard &&
394+
echo "orig content" >file &&
395+
git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch &&
396+
echo "new content" >expect &&
397+
test_cmp expect file
398+
'
399+
400+
run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' '
401+
test_when_finished git reset --hard &&
402+
git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch &&
403+
echo "new content" >expect &&
404+
test_cmp expect file
405+
'
406+
388407
write_script modify-file <<\EOF
389408
echo "new content" >file
390409
EOF

0 commit comments

Comments
 (0)