git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yann Dirson <ydirson@altern.org>
To: git@vger.kernel.org
Cc: Yann Dirson <ydirson@altern.org>, Yann Dirson <ydirson@free.fr>
Subject: [PATCH v8 2/5] Raw diff output format for bulk moves.
Date: Fri, 29 Oct 2010 00:08:29 +0200	[thread overview]
Message-ID: <1288303712-14662-3-git-send-email-ydirson@altern.org> (raw)
In-Reply-To: <1288303712-14662-1-git-send-email-ydirson@altern.org>

To distinguish the general bulk-move case (where the destination
directory was pre-existing) from the directory-rename case (where it
was not), the output of raw diff is displayed as "Rnnn a/* b/".  Those
cannot be confused with renames of files named "whatever/*" with a
literal star character, from the full-zero SHA1's.

Signed-off-by: Yann Dirson <ydirson@free.fr>
---
 Documentation/gitdiffcore.txt |    2 +-
 diff.c                        |    9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/gitdiffcore.txt b/Documentation/gitdiffcore.txt
index 93111ac..2538dc0 100644
--- a/Documentation/gitdiffcore.txt
+++ b/Documentation/gitdiffcore.txt
@@ -181,7 +181,7 @@ additional pass on top of the results of per-file rename detection.
 They are reported with NULL SHA1 id, in addition to the file renames:
 
 ------------------------------------------------
-:040000 040000 0000000... 0000000... R100 foo/ bar/
+:040000 040000 0000000... 0000000... R100 foo/* bar/
 :100644 100644 0123456... 1234567... R090 foo/file0 bar/file3
 :100644 100644 2345678... 2345678... R100 foo/file1 bar/file1
 :100644 100644 3456789... 3456789... R100 foo/file2 bar/file2
diff --git a/diff.c b/diff.c
index 2eba335..948eb76 100644
--- a/diff.c
+++ b/diff.c
@@ -3490,7 +3490,14 @@ static void diff_flush_raw(struct diff_filepair *p, struct diff_options *opt)
 	if (p->status == DIFF_STATUS_COPIED ||
 	    p->status == DIFF_STATUS_RENAMED) {
 		const char *name_a, *name_b;
-		name_a = p->one->path;
+		if (p->is_bulkmove) {
+			/* append "*" to the first dirname */
+			char buf[PATH_MAX];
+			char *next = memccpy(buf, p->one->path, '\0', PATH_MAX);
+			next[-1] = '*'; *next = '\0';
+			name_a = buf;
+		} else
+			name_a = p->one->path;
 		name_b = p->two->path;
 		strip_prefix(opt->prefix_length, &name_a, &name_b);
 		write_name_quoted(name_a, opt->file, inter_name_termination);
-- 
1.7.2.3

  parent reply	other threads:[~2010-10-28 22:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-28 22:08 [PATCH v8] Detection of directory renames Yann Dirson
2010-10-28 22:08 ` [PATCH v8 1/5] Introduce bulk-move detection in diffcore Yann Dirson
2010-10-29  1:45   ` Jonathan Nieder
2010-10-29 21:18     ` Yann Dirson
2010-10-30  0:26       ` Jonathan Nieder
2010-11-04 21:56         ` Yann Dirson
2010-11-04 21:59         ` [PATCH] " Yann Dirson
2010-11-25 10:08   ` [PATCH v8 1/5] " Ævar Arnfjörð Bjarmason
2010-11-25 15:02     ` Jonathan Nieder
2010-11-25 17:19       ` Ævar Arnfjörð Bjarmason
2010-10-28 22:08 ` Yann Dirson [this message]
2010-10-28 22:08 ` [PATCH v8 3/5] Add testcases for the --detect-bulk-moves diffcore flag Yann Dirson
2010-10-28 22:08 ` [PATCH v8 4/5] Unified diff output format for bulk moves Yann Dirson
2010-10-28 22:08 ` [PATCH v8 5/5] [WIP] Allow hiding renames of individual files involved in a directory rename Yann Dirson
2010-10-29  1:05 ` [PATCH v8] Detection of directory renames Jonathan Nieder

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=1288303712-14662-3-git-send-email-ydirson@altern.org \
    --to=ydirson@altern.org \
    --cc=git@vger.kernel.org \
    --cc=ydirson@free.fr \
    /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).