Skip to content

Commit 3cb5673

Browse files
dschogitster
authored andcommitted
diff --no-index: fix --name-status with added files
Without this patch, an added file would be reported as /dev/null. Noticed by David Kastrup. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9cb18f5 commit 3cb5673

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2407,7 +2407,8 @@ static void diff_flush_raw(struct diff_filepair *p,
24072407
printf("%s ",
24082408
diff_unique_abbrev(p->two->sha1, abbrev));
24092409
}
2410-
printf("%s%c%s", status, inter_name_termination, path_one);
2410+
printf("%s%c%s", status, inter_name_termination,
2411+
two_paths || p->one->mode ? path_one : path_two);
24112412
if (two_paths)
24122413
printf("%c%s", inter_name_termination, path_two);
24132414
putchar(line_termination);

t/t4013-diff-various.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ test_expect_success setup '
1717
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
1818
1919
mkdir dir &&
20+
mkdir dir2 &&
2021
for i in 1 2 3; do echo $i; done >file0 &&
2122
for i in A B; do echo $i; done >dir/sub &&
2223
cat file0 >file2 &&
@@ -252,6 +253,7 @@ diff --patch-with-stat initial..side
252253
diff --patch-with-raw initial..side
253254
diff --patch-with-stat -r initial..side
254255
diff --patch-with-raw -r initial..side
256+
diff --name-status dir2 dir
255257
EOF
256258

257259
test_done
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$ git diff --name-status dir2 dir
2+
A dir/sub
3+
$

0 commit comments

Comments
 (0)