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 <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
David Aguilar committed
Dec 9, 2016 at 00:58 UTC
e6e3e2a67c8dacb0ed726f09cf203568f24f8e74
1 file changed
+2
-3
git-difftool.perl
+2
-3
@@ -224,9 +224,7 @@ EOF
224
delete($ENV{GIT_INDEX_FILE});
225
226
# 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.
228
for my $file (@working_tree) {
229
my $dir = dirname($file);
230
unless (-d "$rdir/$dir") {
@@ -389,6 +387,7 @@ sub dir_diff
387
my $repo = Git->repository();
388
my $repo_path = $repo->repo_path();
389
my $workdir = $repo->wc_path();
390
+ $workdir =~ s|/$||; # Avoid double slashes in symlink targets
391
my ($a, $b, $tmpdir, @worktree) = setup_dir_diff($workdir, $symlinks);
392
393
if (defined($extcmd)) {