git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] [RFC] Transfer special display of toplevel dir to display-time.

From
Yann Dirson <ydirson@altern.org>
Date
Oct 10, 2010, 19:59 UTC
Message-ID
<1286740795-7929-3-git-send-email-ydirson@altern.org>
In-Reply-To
<1286740795-7929-2-git-send-email-ydirson@altern.org>

I have mixed feelings about this one: it makes the display code much more messy than the rename code was, and it will need to be duplicated for each output format.

So I suggest to finally just keep the "./" assignation in diffcore_rename.
Any better idea ?
---
 diff.c            |   22 +++++++++++++++-------
 diffcore-rename.c |    5 -----
 2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/diff.c b/diff.c
index 4de43d6..6fe47c2 100644
--- a/diff.c
+++ b/diff.c
@@ -3471,15 +3471,23 @@ 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;
+		char buf[PATH_MAX];
+		name_a = p->one->path;
+		name_b = p->two->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;
+			if (!*name_a)
+				name_a = "./*"; /* visualize toplevel dir */
+			else {
+				/* append "*" to the first dirname */
+				char* next = memccpy(buf, name_a, '\0', PATH_MAX);
+				next[-1] = '*'; *next = '\0';
+				name_a = buf;
+			}
 		} else
-			name_a = p->one->path;
-		name_b = p->two->path;
+			if (!*name_a)
+				name_a = "./"; /* visualize toplevel dir */
+		if (!*name_b)
+			name_b = "./"; /* visualize toplevel dir */
 		strip_prefix(opt->prefix_length, &name_a, &name_b);
 		write_name_quoted(name_a, opt->file, inter_name_termination);
 		write_name_quoted(name_b, opt->file, line_termination);
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 8de0d57..a075a25 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -821,11 +821,6 @@ void diffcore_rename(struct diff_options *options)
 	for (candidate=bulkmove_candidates; candidate; candidate = candidate->next) {
 		struct diff_filepair* pair;
 		if (candidate->discarded) continue;
-		/* visualize toplevel dir if needed */ //FIXME: wrong place for this ?
-		if (!*candidate->one->path)
-			candidate->one->path = "./";
-		if (!*candidate->two->path)
-			candidate->two->path = "./";
 		pair = diff_queue(&outq, candidate->one, candidate->two);
 		pair->score = MAX_SCORE;
 		pair->renamed_pair = 1;
-- 
1.7.2.3
Previous: Yann Dirson
Message 9 of 9 in “Detection of directory renames”
  1. 0/4 Detection of directory renamesYann Dirson, Oct 9, 2010
  2. 1/4 Introduce bulk-move detection in diffcore.Yann Dirson, Oct 9, 2010
  3. 2/4 Add testcases for the --detect-bulk-moves diffcore flag.Yann Dirson, Oct 9, 2010
  4. 3/4 [RFC] Only show bulkmoves in output.Yann Dirson, Oct 9, 2010
  5. 4/4 [RFC] Allow hiding renames of individual files involved in a directory rename.Yann Dirson, Oct 9, 2010
  6. Yann DirsonOct 10, 2010
  7. 0/2 Re: [PATCH v5 3/4] [RFC] Only show bulkmoves in output.Yann Dirson, Oct 10, 2010
  8. 1/2 [RFC] Only show bulkmoves in output.Yann Dirson, Oct 10, 2010
  9. 2/2 [RFC] Transfer special display of toplevel dir to display-time.Yann Dirson, Oct 10, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.