Skip to content

Commit 6e513ba

Browse files
committed
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 <[email protected]>
1 parent ab9d75a commit 6e513ba

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

revision.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,15 +1949,18 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c
19491949
}
19501950

19511951
/*
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.
19541955
*/
19551956
for (cnt = 0, p = commit->parents; p; p = p->next) {
19561957
pst = locate_simplify_state(revs, p->item);
19571958
if (!pst->simplified) {
19581959
tail = &commit_list_insert(p->item, tail)->next;
19591960
cnt++;
19601961
}
1962+
if (revs->first_parent_only)
1963+
break;
19611964
}
19621965
if (cnt) {
19631966
tail = &commit_list_insert(commit, tail)->next;
@@ -1970,8 +1973,13 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c
19701973
for (p = commit->parents; p; p = p->next) {
19711974
pst = locate_simplify_state(revs, p->item);
19721975
p->item = pst->simplified;
1976+
if (revs->first_parent_only)
1977+
break;
19731978
}
1974-
cnt = remove_duplicate_parents(commit);
1979+
if (!revs->first_parent_only)
1980+
cnt = remove_duplicate_parents(commit);
1981+
else
1982+
cnt = 1;
19751983

19761984
/*
19771985
* It is possible that we are a merge and one side branch

0 commit comments

Comments
 (0)