summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-03-28 21:37:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-03-28 21:37:53 (GMT)
commit436b60ce7aac4cf8e496c57c9baae46094571b22 (patch)
tree7caa04a8f179fa651146ea2ab03fd5724ba5088d /revision.c
parent39c5835dd68473e6b829d94533e892cffee09286 (diff)
parent4b7f53da7618e94985c9d9d5081b4bc44c45de2f (diff)
downloadgit-436b60ce7aac4cf8e496c57c9baae46094571b22.zip
git-436b60ce7aac4cf8e496c57c9baae46094571b22.tar.gz
git-436b60ce7aac4cf8e496c57c9baae46094571b22.tar.bz2
Merge branch 'jc/remove-treesame-parent-in-simplify-merges'
The --simplify-merges logic did not cull irrelevant parents from a merge that is otherwise not interesting with respect to the paths we are following. This touches a fairly core part of the revision traversal infrastructure; even though I think this change is correct, please report immediately if you find any unintended side effect. * jc/remove-treesame-parent-in-simplify-merges: simplify-merges: drop merge from irrelevant side branch
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/revision.c b/revision.c
index ef60205..78397d6 100644
--- a/revision.c
+++ b/revision.c
@@ -1970,6 +1970,22 @@ static struct merge_simplify_state *locate_simplify_state(struct rev_info *revs,
return st;
}
+static void remove_treesame_parents(struct commit *commit)
+{
+ struct commit_list **pp, *p;
+
+ pp = &commit->parents;
+ while ((p = *pp) != NULL) {
+ struct commit *parent = p->item;
+ if (parent->object.flags & TREESAME) {
+ *pp = p->next;
+ free(p);
+ continue;
+ }
+ pp = &p->next;
+ }
+}
+
static struct commit_list **simplify_one(struct rev_info *revs, struct commit *commit, struct commit_list **tail)
{
struct commit_list *p;
@@ -2022,10 +2038,18 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c
if (revs->first_parent_only)
break;
}
- if (!revs->first_parent_only)
- cnt = remove_duplicate_parents(commit);
- else
+
+ if (revs->first_parent_only) {
cnt = 1;
+ } else {
+ /*
+ * A merge with a tree-same parent is useless
+ */
+ if (commit->parents && commit->parents->next)
+ remove_treesame_parents(commit);
+
+ cnt = remove_duplicate_parents(commit);
+ }
/*
* It is possible that we are a merge and one side branch