Skip to content

Commit 9ec26e7

Browse files
johnkeepinggitster
authored andcommitted
difftool: fix argument handling in subdirs
When in a subdirectory of a repository, path arguments should be interpreted relative to the current directory not the root of the working tree. The Git::repository object passed into setup_dir_diff() is configured to handle this correctly but we create a new Git::repository here without setting the WorkingSubdir argument. By simply using the existing repository, path arguments are handled relative to the current directory. Reported-by: Bernhard Kirchen <[email protected]> Signed-off-by: John Keeping <[email protected]> Acked-by: David Aguilar <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 05219a1 commit 9ec26e7

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

git-difftool.perl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,9 @@ sub setup_dir_diff
115115
{
116116
my ($repo, $workdir, $symlinks) = @_;
117117

118-
# Run the diff; exit immediately if no diff found
119-
# 'Repository' and 'WorkingCopy' must be explicitly set to insure that
120-
# if $GIT_DIR and $GIT_WORK_TREE are set in ENV, they are actually used
121-
# by Git->repository->command*.
122118
my $repo_path = $repo->repo_path();
123-
my %repo_args = (Repository => $repo_path, WorkingCopy => $workdir);
124-
my $diffrepo = Git->repository(%repo_args);
125-
126119
my @gitargs = ('diff', '--raw', '--no-abbrev', '-z', @ARGV);
127-
my $diffrtn = $diffrepo->command_oneline(@gitargs);
120+
my $diffrtn = $repo->command_oneline(@gitargs);
128121
exit(0) unless defined($diffrtn);
129122

130123
# Build index info for left and right sides of the diff
@@ -176,12 +169,12 @@ sub setup_dir_diff
176169

177170
if ($lmode eq $symlink_mode) {
178171
$symlink{$src_path}{left} =
179-
$diffrepo->command_oneline('show', "$lsha1");
172+
$repo->command_oneline('show', "$lsha1");
180173
}
181174

182175
if ($rmode eq $symlink_mode) {
183176
$symlink{$dst_path}{right} =
184-
$diffrepo->command_oneline('show', "$rsha1");
177+
$repo->command_oneline('show', "$rsha1");
185178
}
186179

187180
if ($lmode ne $null_mode and $status !~ /^C/) {

0 commit comments

Comments
 (0)