From: Johannes Schindelin Date: Tue, 3 Jul 2007 15:01:06 +0000 (+0100) Subject: diff --no-index: fix --name-status with added files X-Git-Tag: v1.5.2.4~11 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3cb567386d5d0349bfb5e3aaf85e973faf685dda;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/diff.c b/diff.c index dc6da5e25..da992dd48 100644 --- a/diff.c +++ b/diff.c @@ -2407,7 +2407,8 @@ static void diff_flush_raw(struct diff_filepair *p, printf("%s ", diff_unique_abbrev(p->two->sha1, abbrev)); } - printf("%s%c%s", status, inter_name_termination, path_one); + printf("%s%c%s", status, inter_name_termination, + two_paths || p->one->mode ? path_one : path_two); if (two_paths) printf("%c%s", inter_name_termination, path_two); putchar(line_termination); diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 8f4c29a6b..4e7d68dda 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -17,6 +17,7 @@ test_expect_success setup ' export GIT_AUTHOR_DATE GIT_COMMITTER_DATE && mkdir dir && + mkdir dir2 && for i in 1 2 3; do echo $i; done >file0 && for i in A B; do echo $i; done >dir/sub && cat file0 >file2 && @@ -252,6 +253,7 @@ diff --patch-with-stat initial..side diff --patch-with-raw initial..side diff --patch-with-stat -r initial..side diff --patch-with-raw -r initial..side +diff --name-status dir2 dir EOF test_done diff --git a/t/t4013/diff.diff_--name-status_dir2_dir b/t/t4013/diff.diff_--name-status_dir2_dir new file mode 100644 index 000000000..ef7fdb733 --- /dev/null +++ b/t/t4013/diff.diff_--name-status_dir2_dir @@ -0,0 +1,3 @@ +$ git diff --name-status dir2 dir +A dir/sub +$