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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]