MCPcopy Create free account
hub / github.com/git/git / sort_and_scan_merged_commits

Function sort_and_scan_merged_commits

commit-graph.c:2406–2446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2404}
2405
2406static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)
2407{
2408 uint32_t i, dedup_i = 0;
2409
2410 if (ctx->report_progress)
2411 ctx->progress = start_delayed_progress(
2412 ctx->r,
2413 _("Scanning merged commits"),
2414 ctx->commits.nr);
2415
2416 QSORT(ctx->commits.items, ctx->commits.nr, commit_compare);
2417
2418 ctx->num_extra_edges = 0;
2419 for (i = 0; i < ctx->commits.nr; i++) {
2420 display_progress(ctx->progress, i + 1);
2421
2422 if (i && oideq(&ctx->commits.items[i - 1]->object.oid,
2423 &ctx->commits.items[i]->object.oid)) {
2424 /*
2425 * Silently ignore duplicates. These were likely
2426 * created due to a commit appearing in multiple
2427 * layers of the chain, which is unexpected but
2428 * not invalid. We should make sure there is a
2429 * unique copy in the new layer.
2430 */
2431 } else {
2432 unsigned int num_parents;
2433
2434 ctx->commits.items[dedup_i] = ctx->commits.items[i];
2435 dedup_i++;
2436
2437 num_parents = commit_list_count(ctx->commits.items[i]->parents);
2438 if (num_parents > 2)
2439 ctx->num_extra_edges += num_parents - 1;
2440 }
2441 }
2442
2443 ctx->commits.nr = dedup_i;
2444
2445 stop_progress(&ctx->progress);
2446}
2447
2448static void merge_commit_graphs(struct write_commit_graph_context *ctx,
2449 struct commit_graph *g)

Callers 1

merge_commit_graphsFunction · 0.85

Calls 5

start_delayed_progressFunction · 0.85
display_progressFunction · 0.85
oideqFunction · 0.85
commit_list_countFunction · 0.85
stop_progressFunction · 0.85

Tested by

no test coverage detected