diff options
author | Johannes Sixt <j6t@kdbg.org> | 2018-10-19 18:58:07 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-10-22 10:17:50 +0900 |
commit | ffd04e92e2c512cbbcb99526b064af302b443cb2 (patch) | |
tree | 9b07ef173b3efae42d683ec9a1f276ae88fe3908 /t/t1301-shared-repo.sh | |
parent | Git 2.16.5 (diff) | |
download | tgif-ffd04e92e2c512cbbcb99526b064af302b443cb2.tar.xz |
diff: don't attempt to strip prefix from absolute Windows paths
git diff can be invoked with absolute paths. Typically, this triggers
the --no-index case. Then the absolute paths remain in the file names
that are printed in the output.
There is one peculiarity, though: When the command is invoked from a
a sub-directory in a repository, then it is attempted to strip the
sub-directory from the beginning of relative paths. Yet, to detect a
relative path the code just checks for an initial forward slash.
This mistakes a Windows style path like "D:/base" as a relative path
and the output looks like this, for example:
D:\dir\test\one>git -P diff --numstat D:\dir\base D:\dir\diff
1 1 ir/{base => diff}/1.txt
where the correct output should be
D:\dir\test\one>git -P diff --numstat D:\dir\base D:\dir\diff
1 1 D:/dir/{base => diff}/1.txt
If the sub-directory where 'git diff' is invoked is sufficiently deep
that the prefix becomes longer than the path to be printed, then the
subsequent code accesses the path out of bounds.
Use is_absolute_path() to detect Windows style absolute paths.
One might wonder whether the check for a directory separator that
is visible in the patch context should be changed from == '/' to
is_dir_sep() or not. It turns out not to be necessary. That code
only ever investigates paths that have undergone pathspec
normalization, after which there are only forward slashes even on
Windows.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1301-shared-repo.sh')
0 files changed, 0 insertions, 0 deletions