commit-graph.c: pass progress to `verify_one_commit_graph()`

This is the final step to prepare for consolidating the output of `git commit-graph verify`. Instead of having each call to `verify_one_commit_graph()` initialize its own progress struct, have the caller pass one in instead. This patch does not alter the output of `git commit-graph verify`, but the next commit will consolidate the output. Signed-off-by: Taylor Blau <me@ttaylorr.com> Acked-by: Derrick Stolee <derrickstolee@github.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Jul 7, 2023 at 20:31 UTC 7248857b6e74bb989dd067d2ac53605e77764700
1 file changed +9 -8
commit-graph.c
+9 -8
@@ -2545,12 +2545,11 @@ static int commit_graph_checksum_valid(struct commit_graph *g)
2545
2546 static int verify_one_commit_graph(struct repository *r,
2547 struct commit_graph *g,
2548 - int flags)
2548 + struct progress *progress)
2549 {
2550 uint32_t i, cur_fanout_pos = 0;
2551 struct object_id prev_oid, cur_oid;
2552 int generation_zero = 0;
2553 - struct progress *progress = NULL;
2553
2554 verify_commit_graph_error = verify_commit_graph_lite(g);
2555 if (verify_commit_graph_error)
@@ -2601,10 +2600,6 @@ static int verify_one_commit_graph(struct repository *r,
2600 if (verify_commit_graph_error & ~VERIFY_COMMIT_GRAPH_ERROR_HASH)
2601 return verify_commit_graph_error;
2602
2604 - if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
2605 - progress = start_progress(_("Verifying commits in commit graph"),
2606 - g->num_commits);
2607 -
2603 for (i = 0; i < g->num_commits; i++) {
2604 struct commit *graph_commit, *odb_commit;
2605 struct commit_list *graph_parents, *odb_parents;
@@ -2694,7 +2689,6 @@ static int verify_one_commit_graph(struct repository *r,
2689 graph_commit->date,
2690 odb_commit->date);
2691 }
2697 - stop_progress(&progress);
2692
2693 return verify_commit_graph_error;
2694 }
@@ -2709,9 +2703,16 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2703 }
2704
2705 for (; g; g = g->base_graph) {
2712 - local_error |= verify_one_commit_graph(r, g, flags);
2706 + struct progress *progress = NULL;
2707 + if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
2708 + progress = start_progress(_("Verifying commits in commit graph"),
2709 + g->num_commits);
2710 +
2711 + local_error |= verify_one_commit_graph(r, g, progress);
2712 if (flags & COMMIT_GRAPH_VERIFY_SHALLOW)
2713 break;
2714 +
2715 + stop_progress(&progress);
2716 }
2717
2718 return local_error;