summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Aguilar <davvid@gmail.com>2016-12-09 00:58:46 -0800
committerJunio C Hamano <gitster@pobox.com>2016-12-11 16:18:53 -0800
commite6e3e2a67c8dacb0ed726f09cf203568f24f8e74 (patch)
tree9cc84e961e75bdc711ecb888dc7aa989bbfed1c1
parent86defcbe3f6c54a31dc898cb3adb4a3b25f1eb1a (diff)
downloadgit-e6e3e2a67c8dacb0ed726f09cf203568f24f8e74.tar.gz
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>
-rwxr-xr-xgit-difftool.perl5
1 files changed, 2 insertions, 3 deletions
diff --git a/git-difftool.perl b/git-difftool.perl
index 959822d5f3..17c336321f 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -224,9 +224,7 @@ EOF
delete($ENV{GIT_INDEX_FILE});
# Changes in the working tree need special treatment since they are
- # not part of the index. Remove any trailing slash from $workdir
- # before starting to avoid double slashes in symlink targets.
- $workdir =~ s|/$||;
+ # not part of the index.
for my $file (@working_tree) {
my $dir = dirname($file);
unless (-d "$rdir/$dir") {
@@ -389,6 +387,7 @@ sub dir_diff
my $repo = Git->repository();
my $repo_path = $repo->repo_path();
my $workdir = $repo->wc_path();
+ $workdir =~ s|/$||; # Avoid double slashes in symlink targets
my ($a, $b, $tmpdir, @worktree) = setup_dir_diff($workdir, $symlinks);
if (defined($extcmd)) {