MCPcopy Index your code
hub / github.com/git/git / simplify_one

Function simplify_one

revision.c:3510–3620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3508}
3509
3510static struct commit_list **simplify_one(struct rev_info *revs, struct commit *commit, struct commit_list **tail)
3511{
3512 struct commit_list *p;
3513 struct commit *parent;
3514 struct merge_simplify_state *st, *pst;
3515 int cnt;
3516
3517 st = locate_simplify_state(revs, commit);
3518
3519 /*
3520 * Have we handled this one?
3521 */
3522 if (st->simplified)
3523 return tail;
3524
3525 /*
3526 * An UNINTERESTING commit simplifies to itself, so does a
3527 * root commit. We do not rewrite parents of such commit
3528 * anyway.
3529 */
3530 if ((commit->object.flags & UNINTERESTING) || !commit->parents) {
3531 st->simplified = commit;
3532 return tail;
3533 }
3534
3535 /*
3536 * Do we know what commit all of our parents that matter
3537 * should be rewritten to? Otherwise we are not ready to
3538 * rewrite this one yet.
3539 */
3540 for (cnt = 0, p = commit->parents; p; p = p->next) {
3541 pst = locate_simplify_state(revs, p->item);
3542 if (!pst->simplified) {
3543 tail = &commit_list_insert(p->item, tail)->next;
3544 cnt++;
3545 }
3546 if (revs->first_parent_only)
3547 break;
3548 }
3549 if (cnt) {
3550 tail = &commit_list_insert(commit, tail)->next;
3551 return tail;
3552 }
3553
3554 /*
3555 * Rewrite our list of parents. Note that this cannot
3556 * affect our TREESAME flags in any way - a commit is
3557 * always TREESAME to its simplification.
3558 */
3559 for (p = commit->parents; p; p = p->next) {
3560 pst = locate_simplify_state(revs, p->item);
3561 p->item = pst->simplified;
3562 if (revs->first_parent_only)
3563 break;
3564 }
3565
3566 if (revs->first_parent_only)
3567 cnt = 1;

Callers 1

simplify_mergesFunction · 0.85

Calls 8

locate_simplify_stateFunction · 0.85
commit_list_insertFunction · 0.85
remove_duplicate_parentsFunction · 0.85
mark_redundant_parentsFunction · 0.85
remove_marked_parentsFunction · 0.85
one_relevant_parentFunction · 0.85

Tested by

no test coverage detected