@@ -59,14 +59,14 @@ sub exit_cleanup
59
59
60
60
sub use_wt_file
61
61
{
62
- my ($workdir , $ file , $sha1 ) = @_ ;
62
+ my ($file , $sha1 ) = @_ ;
63
63
my $null_sha1 = ' 0' x 40 ;
64
64
65
- if (-l " $workdir / $ file" || ! -e _) {
65
+ if (-l $ file || ! -e _) {
66
66
return (0, $null_sha1 );
67
67
}
68
68
69
- my $wt_sha1 = Git::command_oneline(' hash-object' , " $workdir / $ file" );
69
+ my $wt_sha1 = Git::command_oneline(' hash-object' , $ file );
70
70
my $use = ($sha1 eq $null_sha1 ) || ($sha1 eq $wt_sha1 );
71
71
return ($use , $wt_sha1 );
72
72
}
@@ -105,6 +105,12 @@ sub setup_dir_diff
105
105
my $diffrtn = Git::command_oneline(@gitargs );
106
106
exit (0) unless defined ($diffrtn );
107
107
108
+ # Go to the root of the worktree now that we've captured the list of
109
+ # changed files. The paths returned by diff --raw are relative to the
110
+ # top-level of the repository, but we defer changing directories so
111
+ # that @ARGV can perform pathspec limiting in the current directory.
112
+ chdir ($workdir );
113
+
108
114
# Build index info for left and right sides of the diff
109
115
my $submodule_mode = ' 160000' ;
110
116
my $symlink_mode = ' 120000' ;
@@ -172,7 +178,7 @@ sub setup_dir_diff
172
178
next ;
173
179
}
174
180
my ($use , $wt_sha1 ) =
175
- use_wt_file($workdir , $ dst_path , $rsha1 );
181
+ use_wt_file($dst_path , $rsha1 );
176
182
if ($use ) {
177
183
push @working_tree , $dst_path ;
178
184
$wtindex .= " $rmode $wt_sha1 \t $dst_path \0 " ;
@@ -182,10 +188,6 @@ sub setup_dir_diff
182
188
}
183
189
}
184
190
185
- # Go to the root of the worktree so that the left index files
186
- # are properly setup -- the index is toplevel-relative.
187
- chdir ($workdir );
188
-
189
191
# Setup temp directories
190
192
my $tmpdir = tempdir(' git-difftool.XXXXX' , CLEANUP => 0, TMPDIR => 1);
191
193
my $ldir = " $tmpdir /left" ;
@@ -235,10 +237,10 @@ sub setup_dir_diff
235
237
symlink (" $workdir /$file " , " $rdir /$file " ) or
236
238
exit_cleanup($tmpdir , 1);
237
239
} else {
238
- copy(" $workdir / $ file" , " $rdir /$file " ) or
240
+ copy($ file , " $rdir /$file " ) or
239
241
exit_cleanup($tmpdir , 1);
240
242
241
- my $mode = stat (" $workdir / $ file" )-> mode;
243
+ my $mode = stat ($ file )-> mode;
242
244
chmod ($mode , " $rdir /$file " ) or
243
245
exit_cleanup($tmpdir , 1);
244
246
}
@@ -430,10 +432,10 @@ sub dir_diff
430
432
$error = 1;
431
433
} elsif (exists $tmp_modified {$file }) {
432
434
my $mode = stat (" $b /$file " )-> mode;
433
- copy(" $b /$file " , " $workdir / $ file" ) or
435
+ copy(" $b /$file " , $ file ) or
434
436
exit_cleanup($tmpdir , 1);
435
437
436
- chmod ($mode , " $workdir / $ file" ) or
438
+ chmod ($mode , $ file ) or
437
439
exit_cleanup($tmpdir , 1);
438
440
}
439
441
}
0 commit comments