Skip to content

Commit

Permalink
Merge branch 'da/difftool' into maint
Browse files Browse the repository at this point in the history
"git difftool" learned to handle unmerged paths correctly in
dir-diff mode.

* da/difftool:
  difftool: handle unmerged files in dir-diff mode
  difftool: initialize variables for readability
  • Loading branch information
gitster committed Jun 6, 2016
2 parents 7dcbf89 + 366f9ce commit 389c328
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
9 changes: 7 additions & 2 deletions git-difftool.perl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ sub setup_dir_diff
my %submodule;
my %symlink;
my @working_tree = ();
my %working_tree_dups = ();
my @rawdiff = split('\0', $diffrtn);

my $i = 0;
Expand Down Expand Up @@ -188,6 +189,10 @@ sub setup_dir_diff
}

if ($rmode ne $null_mode) {
# Avoid duplicate working_tree entries
if ($working_tree_dups{$dst_path}++) {
next;
}
my ($use, $wt_sha1) = use_wt_file($repo, $workdir,
$dst_path, $rsha1);
if ($use) {
Expand Down Expand Up @@ -273,7 +278,7 @@ sub setup_dir_diff
# temporary file to both the left and right directories to show the
# change in the recorded SHA1 for the submodule.
for my $path (keys %submodule) {
my $ok;
my $ok = 0;
if (defined($submodule{$path}{left})) {
$ok = write_to_file("$ldir/$path",
"Subproject commit $submodule{$path}{left}");
Expand All @@ -289,7 +294,7 @@ sub setup_dir_diff
# shows only the link itself, not the contents of the link target.
# This loop replicates that behavior.
for my $path (keys %symlink) {
my $ok;
my $ok = 0;
if (defined($symlink{$path}{left})) {
$ok = write_to_file("$ldir/$path",
$symlink{$path}{left});
Expand Down
23 changes: 23 additions & 0 deletions t/t7800-difftool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,29 @@ run_dir_diff_test 'difftool --dir-diff when worktree file is missing' '
grep file2 output
'

run_dir_diff_test 'difftool --dir-diff with unmerged files' '
test_when_finished git reset --hard &&
test_config difftool.echo.cmd "echo ok" &&
git checkout -B conflict-a &&
git checkout -B conflict-b &&
git checkout conflict-a &&
echo a >>file &&
git add file &&
git commit -m conflict-a &&
git checkout conflict-b &&
echo b >>file &&
git add file &&
git commit -m conflict-b &&
git checkout master &&
git merge conflict-a &&
test_must_fail git merge conflict-b &&
cat >expect <<-EOF &&
ok
EOF
git difftool --dir-diff $symlinks -t echo >actual &&
test_cmp expect actual
'

write_script .git/CHECK_SYMLINKS <<\EOF
for f in file file2 sub/sub
do
Expand Down

0 comments on commit 389c328

Please sign in to comment.