Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 01e13d0

Browse files
committed
Merge branch 'da/difftool-git-files' into maint
"git difftool" misbehaved when the repository is bound to the working tree with the ".git file" mechanism, where a textual file ".git" tells us where it is. * da/difftool-git-files: t7800: add a difftool test for .git-files difftool: support repositories with .git-files
2 parents 4097a25 + fcfec8b commit 01e13d0

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

git-difftool.perl

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,10 @@ sub usage
3939

4040
sub find_worktree
4141
{
42-
my ($repo) = @_;
43-
4442
# Git->repository->wc_path() does not honor changes to the working
4543
# tree location made by $ENV{GIT_WORK_TREE} or the 'core.worktree'
4644
# config variable.
47-
my $worktree;
48-
my $env_worktree = $ENV{GIT_WORK_TREE};
49-
my $core_worktree = Git::config('core.worktree');
50-
51-
if (defined($env_worktree) and (length($env_worktree) > 0)) {
52-
$worktree = $env_worktree;
53-
} elsif (defined($core_worktree) and (length($core_worktree) > 0)) {
54-
$worktree = $core_worktree;
55-
} else {
56-
$worktree = $repo->wc_path();
57-
}
58-
59-
return $worktree;
45+
return Git::command_oneline('rev-parse', '--show-toplevel');
6046
}
6147

6248
sub print_tool_help
@@ -418,7 +404,7 @@ sub dir_diff
418404
my $rc;
419405
my $error = 0;
420406
my $repo = Git->repository();
421-
my $workdir = find_worktree($repo);
407+
my $workdir = find_worktree();
422408
my ($a, $b, $tmpdir, @worktree) =
423409
setup_dir_diff($repo, $workdir, $symlinks);
424410

t/t7800-difftool.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,18 @@ test_expect_success PERL 'difftool --no-symlinks detects conflict ' '
434434
)
435435
'
436436

437+
test_expect_success PERL 'difftool properly honors gitlink and core.worktree' '
438+
git submodule add ./. submod/ule &&
439+
(
440+
cd submod/ule &&
441+
test_config diff.tool checktrees &&
442+
test_config difftool.checktrees.cmd '\''
443+
test -d "$LOCAL" && test -d "$REMOTE" && echo good
444+
'\'' &&
445+
echo good >expect &&
446+
git difftool --tool=checktrees --dir-diff HEAD~ >actual &&
447+
test_cmp expect actual
448+
)
449+
'
450+
437451
test_done

0 commit comments

Comments
 (0)