revision: ignore side parents while running simplify-merges

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>

Junio C Hamano committed Jun 8, 2012 at 14:56 UTC 6e513ba3a624a57fcf9e0f316ba54b3e0c951286
1 file changed +11 -3
revision.c
+11 -3
@@ -1949,8 +1949,9 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c
1949 }
1950
1951 /*
1952 - * Do we know what commit all of our parents should be rewritten to?
1953 - * Otherwise we are not ready to rewrite this one yet.
1952 + * Do we know what commit all of our parents that matter
1953 + * should be rewritten to? Otherwise we are not ready to
1954 + * rewrite this one yet.
1955 */
1956 for (cnt = 0, p = commit->parents; p; p = p->next) {
1957 pst = locate_simplify_state(revs, p->item);
@@ -1958,6 +1959,8 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c
1959 tail = &commit_list_insert(p->item, tail)->next;
1960 cnt++;
1961 }
1962 + if (revs->first_parent_only)
1963 + break;
1964 }
1965 if (cnt) {
1966 tail = &commit_list_insert(commit, tail)->next;
@@ -1970,8 +1973,13 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c
1973 for (p = commit->parents; p; p = p->next) {
1974 pst = locate_simplify_state(revs, p->item);
1975 p->item = pst->simplified;
1976 + if (revs->first_parent_only)
1977 + break;
1978 }
1974 - cnt = remove_duplicate_parents(commit);
1979 + if (!revs->first_parent_only)
1980 + cnt = remove_duplicate_parents(commit);
1981 + else
1982 + cnt = 1;
1983
1984 /*
1985 * It is possible that we are a merge and one side branch