From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] combine-diff: Record diff status a bit more faithfully
Date: Fri, 10 Feb 2006 03:00:45 -0800 [thread overview]
Message-ID: <7vzmkzwk9u.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 7vzml08cfm.fsf@assigned-by-dhcp.cox.net
This shows "new file mode XXXX" and "deleted file mode XXXX"
lines like two-way diff-patch output does, by checking the
status from each parent.
The diff-raw output for combined diff is made a bit uglier by
showing diff status letters with each parent. While most of the
case you would see "MM" in the output, an Evil Merge that
touches a path that was added by inheriting from one parent is
possible and it would be shown like these:
$ git-diff-tree --abbrev -c HEAD
2d7ca89675eb8888b0b88a91102f096d4471f09f
::000000 000000 100644 0000000... 0000000... 31dd686... AA b
::000000 100644 100644 0000000... 6c884ae... c6d4fa8... AM d
::100644 100644 100644 4f7cbe7... f8c295c... 19d5d80... RR e
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
* I also considered showing the rename detection scores but
felt it was too much information, so refrained from it.
Maybe MM might be too much, but knowing most of the merges
are only two parents' kind, one extra column would not be too
much noise.
By looking at -c -p or --cc output, you cannot tell any
renames, which makes me feel a bit uneasy. I suspect this
is going into purely academic realm and would not be useful
in practice at all, so I'd say we should stop ;-).
combine-diff.c | 32 +++++++++++++++++++++++++-------
diff.h | 1 +
2 files changed, 26 insertions(+), 7 deletions(-)
dc33c79b0f69a1e9acee740a2f7ac5eacfdd49ce
diff --git a/combine-diff.c b/combine-diff.c
index 8ba6949..a38f01b 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -39,6 +39,7 @@ static struct combine_diff_path *interse
p->mode = q->queue[i]->two->mode;
memcpy(p->parent[n].sha1, q->queue[i]->one->sha1, 20);
p->parent[n].mode = q->queue[i]->one->mode;
+ p->parent[n].status = q->queue[i]->status;
*tail = p;
tail = &p->next;
}
@@ -62,6 +63,7 @@ static struct combine_diff_path *interse
memcpy(p->parent[n].sha1,
q->queue[i]->one->sha1, 20);
p->parent[n].mode = q->queue[i]->one->mode;
+ p->parent[n].status = q->queue[i]->status;
break;
}
}
@@ -739,12 +741,25 @@ static int show_patch_diff(struct combin
printf("..%s\n", abb);
if (mode_differs) {
- printf("mode ");
- for (i = 0; i < num_parent; i++) {
- printf("%s%06o", i ? "," : "",
- elem->parent[i].mode);
+ int added = !!elem->mode;
+ for (i = 0; added && i < num_parent; i++)
+ if (elem->parent[i].status !=
+ DIFF_STATUS_ADDED)
+ added = 0;
+ if (added)
+ printf("new file mode %06o", elem->mode);
+ else {
+ if (!elem->mode)
+ printf("deleted file ");
+ printf("mode ");
+ for (i = 0; i < num_parent; i++) {
+ printf("%s%06o", i ? "," : "",
+ elem->parent[i].mode);
+ }
+ if (elem->mode)
+ printf("..%06o", elem->mode);
}
- printf("..%06o\n", elem->mode);
+ putchar('\n');
}
dump_sline(sline, cnt, num_parent);
}
@@ -811,8 +826,11 @@ static void show_raw_diff(struct combine
}
if (opt->output_format == DIFF_FORMAT_RAW ||
- opt->output_format == DIFF_FORMAT_NAME_STATUS)
- printf("%c%c", mod_type, inter_name_termination);
+ opt->output_format == DIFF_FORMAT_NAME_STATUS) {
+ for (i = 0; i < num_parent; i++)
+ putchar(p->parent[i].status);
+ putchar(inter_name_termination);
+ }
if (line_termination) {
if (quote_c_style(p->path, NULL, NULL, 0))
diff --git a/diff.h b/diff.h
index 946a406..8fac465 100644
--- a/diff.h
+++ b/diff.h
@@ -66,6 +66,7 @@ struct combine_diff_path {
unsigned int mode;
unsigned char sha1[20];
struct combine_diff_parent {
+ char status;
unsigned int mode;
unsigned char sha1[20];
} parent[FLEX_ARRAY];
--
1.1.6.g94c6
next prev parent reply other threads:[~2006-02-10 11:00 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-08 23:44 gitweb using "--cc"? Linus Torvalds
2006-02-08 23:57 ` Junio C Hamano
2006-02-09 0:01 ` [PATCH] Use describe to come up with the closest tag Junio C Hamano
2006-02-09 0:02 ` [PATCH] Allow using --cc when showing a merge Junio C Hamano
2006-02-09 2:13 ` gitweb using "--cc"? Brian Gerst
2006-02-09 2:26 ` Linus Torvalds
2006-02-09 3:14 ` Junio C Hamano
2006-02-09 16:35 ` Linus Torvalds
2006-02-09 16:42 ` Linus Torvalds
2006-02-09 18:30 ` Linus Torvalds
2006-02-09 19:41 ` Junio C Hamano
2006-02-09 20:27 ` Linus Torvalds
2006-02-09 20:37 ` Linus Torvalds
2006-02-09 20:47 ` Junio C Hamano
2006-02-09 20:52 ` Junio C Hamano
2006-02-09 21:53 ` Junio C Hamano
2006-02-09 22:00 ` Junio C Hamano
2006-02-09 22:26 ` Junio C Hamano
2006-02-11 9:17 ` Marco Costalba
2006-02-11 19:32 ` Junio C Hamano
2006-02-11 20:59 ` Junio C Hamano
2006-02-09 20:38 ` Junio C Hamano
2006-02-09 20:50 ` Linus Torvalds
2006-02-09 21:11 ` Junio C Hamano
2006-02-10 11:00 ` Junio C Hamano [this message]
2006-02-09 23:49 ` [PATCH] combine-diff: move formatting logic to show_combined_diff() Junio C Hamano
2006-02-09 3:13 ` gitweb using "--cc"? Kay Sievers
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vzmkzwk9u.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).