Skip to content

Commit

Permalink
revision: ignore side parents while running simplify-merges
Browse files Browse the repository at this point in the history
The simplify_merges() function needs to look at all history chain to
find the closest ancestor that is relevant after the simplification,
but after --first-parent traversal, side parents haven't been marked
for relevance (they are irrelevant by definition due to the nature
of first-parent-only traversal) nor culled from the parents list of
resulting commits.

We cannot simply remove these side parents from the parents list, as
the output phase still wants to see the parents.  Instead, teach
simplify_one() and its callees to ignore the later parents.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Jun 13, 2012
1 parent ab9d75a commit 6e513ba
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -1949,15 +1949,18 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c
}

/*
* Do we know what commit all of our parents should be rewritten to?
* Otherwise we are not ready to rewrite this one yet.
* Do we know what commit all of our parents that matter
* should be rewritten to? Otherwise we are not ready to
* rewrite this one yet.
*/
for (cnt = 0, p = commit->parents; p; p = p->next) {
pst = locate_simplify_state(revs, p->item);
if (!pst->simplified) {
tail = &commit_list_insert(p->item, tail)->next;
cnt++;
}
if (revs->first_parent_only)
break;
}
if (cnt) {
tail = &commit_list_insert(commit, tail)->next;
Expand All @@ -1970,8 +1973,13 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c
for (p = commit->parents; p; p = p->next) {
pst = locate_simplify_state(revs, p->item);
p->item = pst->simplified;
if (revs->first_parent_only)
break;
}
cnt = remove_duplicate_parents(commit);
if (!revs->first_parent_only)
cnt = remove_duplicate_parents(commit);
else
cnt = 1;

/*
* It is possible that we are a merge and one side branch
Expand Down

0 comments on commit 6e513ba

Please sign in to comment.