summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8548ea8)
raw | patch | inline | side by side (parent: 8548ea8)
author | Linus Torvalds <torvalds@osdl.org> | |
Tue, 25 Oct 2005 18:50:46 +0000 (11:50 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 26 Oct 2005 05:53:24 +0000 (22:53 -0700) |
Right now --dense will _always_ show the root commit. I didn't do the
logic that does the diff against an empty tree. I was lazy.
This patch does that. The first round was incorrect but
this patch is even slightly tested, and might do a better job.
Signed-off-by: Junio C Hamano <junkio@cox.net>
logic that does the diff against an empty tree. I was lazy.
This patch does that. The first round was incorrect but
this patch is even slightly tested, and might do a better job.
Signed-off-by: Junio C Hamano <junkio@cox.net>
rev-list.c | patch | blob | history |
diff --git a/rev-list.c b/rev-list.c
index 5f125fdf29abeae752580392f4a9a455638acb58..edf3b378745c7f28d00f974c852d064fd5151f13 100644 (file)
--- a/rev-list.c
+++ b/rev-list.c
fflush(stdout);
}
-static void rewrite_one(struct commit **pp)
+static int rewrite_one(struct commit **pp)
{
for (;;) {
struct commit *p = *pp;
if (p->object.flags & (TREECHANGE | UNINTERESTING))
- return;
- /* Only single-parent commits don't have TREECHANGE */
+ return 0;
+ if (!p->parents)
+ return -1;
*pp = p->parents->item;
}
}
static void rewrite_parents(struct commit *commit)
{
- struct commit_list *parent = commit->parents;
- while (parent) {
- rewrite_one(&parent->item);
- parent = parent->next;
+ struct commit_list **pp = &commit->parents;
+ while (*pp) {
+ struct commit_list *parent = *pp;
+ if (rewrite_one(&parent->item) < 0) {
+ *pp = parent->next;
+ continue;
+ }
+ pp = &parent->next;
}
}
return !is_different;
}
+static int same_tree_as_empty(struct tree *t1)
+{
+ int retval;
+ void *tree;
+ struct tree_desc empty, real;
+
+ if (!t1)
+ return 0;
+
+ tree = read_object_with_reference(t1->object.sha1, "tree", &real.size, NULL);
+ if (!tree)
+ return 0;
+ real.buf = tree;
+
+ empty.buf = "";
+ empty.size = 0;
+
+ is_different = 0;
+ retval = diff_tree(&empty, &real, "", &diff_opt);
+ free(tree);
+
+ return retval >= 0 && !is_different;
+}
+
static struct commit *try_to_simplify_merge(struct commit *commit, struct commit_list *parent)
{
if (!commit->tree)
struct commit_list *parent = commit->parents;
list = list->next;
+ if (!parent) {
+ if (!same_tree_as_empty(commit->tree))
+ commit->object.flags |= TREECHANGE;
+ continue;
+ }
+
/*
* Exactly one parent? Check if it leaves the tree
* unchanged
*/
- if (parent && !parent->next) {
+ if (!parent->next) {
struct tree *t1 = commit->tree;
struct tree *t2 = parent->item->tree;
if (!t1 || !t2 || same_tree(t1, t2))