Skip to content

Commit e6e3e2a

Browse files
davvidgitster
authored andcommitted
difftool: sanitize $workdir as early as possible
The double-slash fixup on the $workdir variable was being performed just-in-time to avoid double-slashes in symlink targets, but the rest of the code was silently using paths with embedded "//" in them. A recent user-reported error message contained double-slashes. Eliminate the issue by sanitizing inputs as soon as they arrive. Signed-off-by: David Aguilar <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 86defcb commit e6e3e2a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

git-difftool.perl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ sub setup_dir_diff
224224
delete($ENV{GIT_INDEX_FILE});
225225

226226
# Changes in the working tree need special treatment since they are
227-
# not part of the index. Remove any trailing slash from $workdir
228-
# before starting to avoid double slashes in symlink targets.
229-
$workdir =~ s|/$||;
227+
# not part of the index.
230228
for my $file (@working_tree) {
231229
my $dir = dirname($file);
232230
unless (-d "$rdir/$dir") {
@@ -389,6 +387,7 @@ sub dir_diff
389387
my $repo = Git->repository();
390388
my $repo_path = $repo->repo_path();
391389
my $workdir = $repo->wc_path();
390+
$workdir =~ s|/$||; # Avoid double slashes in symlink targets
392391
my ($a, $b, $tmpdir, @worktree) = setup_dir_diff($workdir, $symlinks);
393392

394393
if (defined($extcmd)) {

0 commit comments

Comments
 (0)