git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: David Kastrup <dak@gnu.org>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: [PATCH] diff --no-index: fix --name-status with added files
Date: Tue, 3 Jul 2007 16:01:06 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0707031559510.4071@racer.site> (raw)
In-Reply-To: <86hcolr3sb.fsf@lola.quinscape.zz>


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>
---

	Would be nice, next time, to have a bug report which is not 
	embedded in a thread.

 diff.c                                   |    3 ++-
 t/t4013-diff-various.sh                  |    2 ++
 t/t4013/diff.diff_--name-status_dir2_dir |    3 +++
 3 files changed, 7 insertions(+), 1 deletions(-)
 create mode 100644 t/t4013/diff.diff_--name-status_dir2_dir

diff --git a/diff.c b/diff.c
index b6eb72b..1958970 100644
--- a/diff.c
+++ b/diff.c
@@ -2418,7 +2418,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 b453b42..9eec754 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 &&
@@ -254,6 +255,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 0000000..ef7fdb7
--- /dev/null
+++ b/t/t4013/diff.diff_--name-status_dir2_dir
@@ -0,0 +1,3 @@
+$ git diff --name-status dir2 dir
+A	dir/sub
+$
-- 
1.5.3.rc0.2637.g1dd84-dirty

  reply	other threads:[~2007-07-03 15:01 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-02 19:54 being nice to patch(1) Andrew Morton
2007-07-02 21:16 ` Linus Torvalds
2007-07-02 21:25   ` Andrew Morton
2007-07-02 21:40     ` Linus Torvalds
2007-07-02 21:56       ` Andrew Morton
2007-07-03  0:28         ` Linus Torvalds
2007-07-03  4:00           ` Junio C Hamano
2007-07-03  4:14             ` Linus Torvalds
2007-07-03 12:04               ` Johannes Schindelin
2007-07-03 12:21                 ` Paolo Ciarrocchi
2007-07-03 12:35                   ` Johannes Schindelin
2007-07-03 18:39                   ` Theodore Tso
2007-07-03 19:48                     ` Linus Torvalds
2007-07-03 20:55                       ` Paul Eggert
2007-07-03 21:30                         ` Linus Torvalds
2007-07-03 21:35                           ` Linus Torvalds
2007-07-03 13:22                 ` David Kastrup
2007-07-03 13:39                   ` Johannes Schindelin
2007-07-03 13:54                     ` David Kastrup
2007-07-03 15:01                       ` Johannes Schindelin [this message]
2007-07-03 15:01                       ` Johannes Schindelin
2007-07-03 15:08                         ` David Kastrup
2007-07-06 12:38                 ` David Kastrup
2007-07-06 15:22                   ` git-diff memory/speed/disk impacts (was: being nice to patch(1)) David Kastrup
2007-07-06 18:08                   ` being nice to patch(1) Linus Torvalds
2007-07-03 13:34           ` [Quilt-dev] " Andreas Gruenbacher
2007-07-03 15:49             ` Andrew Morton
2007-07-03 16:03               ` Linus Torvalds
2007-07-03 16:03               ` Andreas Gruenbacher
2007-07-03 16:15                 ` Andrew Morton
2007-07-03 21:03                 ` Andrew Morton
2007-07-03 21:03             ` Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0707031559510.4071@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=dak@gnu.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).