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

Function close_reachable

commit-graph.c:1558–1617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1556}
1557
1558static void close_reachable(struct write_commit_graph_context *ctx)
1559{
1560 int i;
1561 struct commit *commit;
1562 enum commit_graph_split_flags flags = ctx->opts ?
1563 ctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;
1564
1565 if (ctx->report_progress)
1566 ctx->progress = start_delayed_progress(
1567 ctx->r,
1568 _("Loading known commits in commit graph"),
1569 ctx->oids.nr);
1570 for (i = 0; i < ctx->oids.nr; i++) {
1571 display_progress(ctx->progress, i + 1);
1572 commit = lookup_commit(ctx->r, &ctx->oids.oid[i]);
1573 if (commit)
1574 commit->object.flags |= REACHABLE;
1575 }
1576 stop_progress(&ctx->progress);
1577
1578 /*
1579 * As this loop runs, ctx->oids.nr may grow, but not more
1580 * than the number of missing commits in the reachable
1581 * closure.
1582 */
1583 if (ctx->report_progress)
1584 ctx->progress = start_delayed_progress(
1585 ctx->r,
1586 _("Expanding reachable commits in commit graph"),
1587 0);
1588 for (i = 0; i < ctx->oids.nr; i++) {
1589 display_progress(ctx->progress, i + 1);
1590 commit = lookup_commit(ctx->r, &ctx->oids.oid[i]);
1591
1592 if (!commit)
1593 continue;
1594 if (ctx->split) {
1595 if ((!repo_parse_commit(ctx->r, commit) &&
1596 commit_graph_position(commit) == COMMIT_NOT_FROM_GRAPH) ||
1597 flags == COMMIT_GRAPH_SPLIT_REPLACE)
1598 add_missing_parents(ctx, commit);
1599 } else if (!repo_parse_commit_no_graph(ctx->r, commit))
1600 add_missing_parents(ctx, commit);
1601 }
1602 stop_progress(&ctx->progress);
1603
1604 if (ctx->report_progress)
1605 ctx->progress = start_delayed_progress(
1606 ctx->r,
1607 _("Clearing commit marks in commit graph"),
1608 ctx->oids.nr);
1609 for (i = 0; i < ctx->oids.nr; i++) {
1610 display_progress(ctx->progress, i + 1);
1611 commit = lookup_commit(ctx->r, &ctx->oids.oid[i]);
1612
1613 if (commit)
1614 commit->object.flags &= ~REACHABLE;
1615 }

Callers 1

write_commit_graphFunction · 0.85

Calls 8

start_delayed_progressFunction · 0.85
display_progressFunction · 0.85
lookup_commitFunction · 0.85
stop_progressFunction · 0.85
repo_parse_commitFunction · 0.85
commit_graph_positionFunction · 0.85
add_missing_parentsFunction · 0.85

Tested by

no test coverage detected