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 <bernhard.kirchen@rwth-aachen.de> Signed-off-by: John Keeping <john@keeping.me.uk> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
John Keeping committed
Jul 18, 2016 at 20:57 UTC
9ec26e797781239b36ebccb87c590e5778358007
1 file changed
+3
-10
git-difftool.perl
+3
-10
@@ -115,16 +115,9 @@ sub setup_dir_diff
115
{
116
my ($repo, $workdir, $symlinks) = @_;
117
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*.
118
my $repo_path = $repo->repo_path();
123
- my %repo_args = (Repository => $repo_path, WorkingCopy => $workdir);
124
- my $diffrepo = Git->repository(%repo_args);
125
-
119
my @gitargs = ('diff', '--raw', '--no-abbrev', '-z', @ARGV);
127
- my $diffrtn = $diffrepo->command_oneline(@gitargs);
120
+ my $diffrtn = $repo->command_oneline(@gitargs);
121
exit(0) unless defined($diffrtn);
122
123
# Build index info for left and right sides of the diff
@@ -176,12 +169,12 @@ EOF
169
170
if ($lmode eq $symlink_mode) {
171
$symlink{$src_path}{left} =
179
- $diffrepo->command_oneline('show', "$lsha1");
172
+ $repo->command_oneline('show', "$lsha1");
173
}
174
175
if ($rmode eq $symlink_mode) {
176
$symlink{$dst_path}{right} =
184
- $diffrepo->command_oneline('show', "$rsha1");
177
+ $repo->command_oneline('show', "$rsha1");
178
}
179
180
if ($lmode ne $null_mode and $status !~ /^C/) {