Skip to content

Commit

Permalink
Merge branch 'ks/difftool-dir-diff-copy-fix' into maint
Browse files Browse the repository at this point in the history
* ks/difftool-dir-diff-copy-fix:
  difftool --dir-diff: allow changing any clean working tree file
  • Loading branch information
Junio C Hamano committed Jun 27, 2013
2 parents 6be17ec + 32eaf1d commit 88f90f8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
9 changes: 2 additions & 7 deletions git-difftool.perl
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,9 @@ sub exit_cleanup

sub use_wt_file
{
my ($repo, $workdir, $file, $sha1, $symlinks) = @_;
my ($repo, $workdir, $file, $sha1) = @_;
my $null_sha1 = '0' x 40;

if ($sha1 ne $null_sha1 and not $symlinks) {
return 0;
}

if (! -e "$workdir/$file") {
# If the file doesn't exist in the working tree, we cannot
# use it.
Expand Down Expand Up @@ -213,8 +209,7 @@ sub setup_dir_diff

if ($rmode ne $null_mode) {
my ($use, $wt_sha1) = use_wt_file($repo, $workdir,
$dst_path, $rsha1,
$symlinks);
$dst_path, $rsha1);
if ($use) {
push @working_tree, $dst_path;
$wtindex .= "$rmode $wt_sha1\t$dst_path\0";
Expand Down
19 changes: 19 additions & 0 deletions t/t7800-difftool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,25 @@ test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstage
test_cmp actual expect
'

write_script modify-right-file <<\EOF
echo "new content" >"$2/file"
EOF

run_dir_diff_test 'difftool --dir-diff syncs worktree with unstaged change' '
test_when_finished git reset --hard &&
echo "orig content" >file &&
git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch &&
echo "new content" >expect &&
test_cmp expect file
'

run_dir_diff_test 'difftool --dir-diff syncs worktree without unstaged change' '
test_when_finished git reset --hard &&
git difftool -d $symlinks --extcmd "$(pwd)/modify-right-file" branch &&
echo "new content" >expect &&
test_cmp expect file
'

write_script modify-file <<\EOF
echo "new content" >file
EOF
Expand Down

0 comments on commit 88f90f8

Please sign in to comment.