]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph.c: pass progress to `verify_one_commit_graph()`
authorTaylor Blau <me@ttaylorr.com>
Sat, 8 Jul 2023 00:31:42 +0000 (20:31 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Jul 2023 17:02:43 +0000 (10:02 -0700)
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>
commit-graph.c

index bb56733d8c35e60095780c0781ba1dd77177d309..9e899528316e5925647a7db21b86dfc2479b5425 100644 (file)
@@ -2545,12 +2545,11 @@ static int commit_graph_checksum_valid(struct commit_graph *g)
 
 static int verify_one_commit_graph(struct repository *r,
                                   struct commit_graph *g,
-                                  int flags)
+                                  struct progress *progress)
 {
        uint32_t i, cur_fanout_pos = 0;
        struct object_id prev_oid, cur_oid;
        int generation_zero = 0;
-       struct progress *progress = NULL;
 
        verify_commit_graph_error = verify_commit_graph_lite(g);
        if (verify_commit_graph_error)
@@ -2601,10 +2600,6 @@ static int verify_one_commit_graph(struct repository *r,
        if (verify_commit_graph_error & ~VERIFY_COMMIT_GRAPH_ERROR_HASH)
                return verify_commit_graph_error;
 
-       if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
-               progress = start_progress(_("Verifying commits in commit graph"),
-                                       g->num_commits);
-
        for (i = 0; i < g->num_commits; i++) {
                struct commit *graph_commit, *odb_commit;
                struct commit_list *graph_parents, *odb_parents;
@@ -2694,7 +2689,6 @@ static int verify_one_commit_graph(struct repository *r,
                                     graph_commit->date,
                                     odb_commit->date);
        }
-       stop_progress(&progress);
 
        return verify_commit_graph_error;
 }
@@ -2709,9 +2703,16 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
        }
 
        for (; g; g = g->base_graph) {
-               local_error |= verify_one_commit_graph(r, g, flags);
+               struct progress *progress = NULL;
+               if (flags & COMMIT_GRAPH_WRITE_PROGRESS)
+                       progress = start_progress(_("Verifying commits in commit graph"),
+                                               g->num_commits);
+
+               local_error |= verify_one_commit_graph(r, g, progress);
                if (flags & COMMIT_GRAPH_VERIFY_SHALLOW)
                        break;
+
+               stop_progress(&progress);
        }
 
        return local_error;