Skip to content

Commit 99499e2

Browse files
committed
Merge branch 'js/diff-notice-has-drive-prefix'
Under certain circumstances, "git diff D:/a/b/c D:/a/b/d" on Windows would strip initial parts from the paths because they were not recognized as absolute, which has been corrected. * js/diff-notice-has-drive-prefix: diff: don't attempt to strip prefix from absolute Windows paths
2 parents 9d00100 + ffd04e9 commit 99499e2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4302,12 +4302,12 @@ static void diff_fill_oid_info(struct diff_filespec *one, struct index_state *is
43024302
static void strip_prefix(int prefix_length, const char **namep, const char **otherp)
43034303
{
43044304
/* Strip the prefix but do not molest /dev/null and absolute paths */
4305-
if (*namep && **namep != '/') {
4305+
if (*namep && !is_absolute_path(*namep)) {
43064306
*namep += prefix_length;
43074307
if (**namep == '/')
43084308
++*namep;
43094309
}
4310-
if (*otherp && **otherp != '/') {
4310+
if (*otherp && !is_absolute_path(*otherp)) {
43114311
*otherp += prefix_length;
43124312
if (**otherp == '/')
43134313
++*otherp;

t/t4053-diff-no-index.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,14 @@ test_expect_success 'diff --no-index from repo subdir respects config (implicit)
127127
test_cmp expect actual.head
128128
'
129129

130+
test_expect_success 'diff --no-index from repo subdir with absolute paths' '
131+
cat <<-EOF >expect &&
132+
1 1 $(pwd)/non/git/{a => b}
133+
EOF
134+
test_expect_code 1 \
135+
git -C repo/sub diff --numstat \
136+
"$(pwd)/non/git/a" "$(pwd)/non/git/b" >actual &&
137+
test_cmp expect actual
138+
'
139+
130140
test_done

0 commit comments

Comments
 (0)