Git fork

commit-graph: pass graphs that are to be merged as parameter

When determining whether or not we want to merge a commit graph chain we
retrieve the graph that is to be merged via the context's repository.
With an upcoming change though it will become a bit more complex to
figure out the commit graph, which would lead to code duplication.

Prepare for this change by passing the graph that is to be merged as a
parameter.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
62490b6d 88bc3500

+10 -8
+10 -8
commit-graph.c
··· 2226 2226 return 0; 2227 2227 } 2228 2228 2229 - static void split_graph_merge_strategy(struct write_commit_graph_context *ctx) 2229 + static void split_graph_merge_strategy(struct write_commit_graph_context *ctx, 2230 + struct commit_graph *graph_to_merge) 2230 2231 { 2231 2232 struct commit_graph *g; 2232 2233 uint32_t num_commits; ··· 2245 2246 flags = ctx->opts->split_flags; 2246 2247 } 2247 2248 2248 - g = ctx->r->objects->commit_graph; 2249 + g = graph_to_merge; 2249 2250 num_commits = ctx->commits.nr; 2250 2251 if (flags == COMMIT_GRAPH_SPLIT_REPLACE) 2251 2252 ctx->num_commit_graphs_after = 1; ··· 2297 2298 ctx->commit_graph_filenames_after[i] = xstrdup(ctx->commit_graph_filenames_before[i]); 2298 2299 2299 2300 i = ctx->num_commit_graphs_before - 1; 2300 - g = ctx->r->objects->commit_graph; 2301 + g = graph_to_merge; 2301 2302 2302 2303 while (g) { 2303 2304 if (i < ctx->num_commit_graphs_after) ··· 2395 2396 stop_progress(&ctx->progress); 2396 2397 } 2397 2398 2398 - static void merge_commit_graphs(struct write_commit_graph_context *ctx) 2399 + static void merge_commit_graphs(struct write_commit_graph_context *ctx, 2400 + struct commit_graph *g) 2399 2401 { 2400 - struct commit_graph *g = ctx->r->objects->commit_graph; 2401 2402 uint32_t current_graph_number = ctx->num_commit_graphs_before; 2402 2403 2403 2404 while (g && current_graph_number >= ctx->num_commit_graphs_after) { ··· 2632 2633 goto cleanup; 2633 2634 2634 2635 if (ctx.split) { 2635 - split_graph_merge_strategy(&ctx); 2636 + split_graph_merge_strategy(&ctx, g); 2636 2637 2637 2638 if (!replace) 2638 - merge_commit_graphs(&ctx); 2639 - } else 2639 + merge_commit_graphs(&ctx, g); 2640 + } else { 2640 2641 ctx.num_commit_graphs_after = 1; 2642 + } 2641 2643 2642 2644 ctx.trust_generation_numbers = validate_mixed_generation_chain(g); 2643 2645