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>
Johannes Schindelin committed
Jul 3, 2007 at 16:01 UTC
3cb567386d5d0349bfb5e3aaf85e973faf685dda
3 files changed
+7
-1
diff.c
+2
-1
@@ -2407,7 +2407,8 @@ static void diff_flush_raw(struct diff_filepair *p,
2407
printf("%s ",
2408
diff_unique_abbrev(p->two->sha1, abbrev));
2409
}
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);
2412
if (two_paths)
2413
printf("%c%s", inter_name_termination, path_two);
2414
putchar(line_termination);
t/t4013-diff-various.sh
+2
@@ -17,6 +17,7 @@ test_expect_success setup '
17
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
18
19
mkdir dir &&
20
+ mkdir dir2 &&
21
for i in 1 2 3; do echo $i; done >file0 &&
22
for i in A B; do echo $i; done >dir/sub &&
23
cat file0 >file2 &&
@@ -252,6 +253,7 @@ diff --patch-with-stat initial..side
253
diff --patch-with-raw initial..side
254
diff --patch-with-stat -r initial..side
255
diff --patch-with-raw -r initial..side
256
+diff --name-status dir2 dir
257
EOF
258
259
test_done
t/t4013/diff.diff_--name-status_dir2_dir
new
+3
@@ -0,0 +1,3 @@
1
+$ git diff --name-status dir2 dir
2
+A dir/sub
3
+$