]> git.ipfire.org Git - thirdparty/git.git/commitdiff
commit-graph.c: iteratively verify commit-graph chains
authorTaylor Blau <me@ttaylorr.com>
Sat, 8 Jul 2023 00:31:39 +0000 (20:31 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Jul 2023 17:02:42 +0000 (10:02 -0700)
Now that we have a function which can verify a single layer of a
commit-graph chain, implement `verify_commit_graph()` in terms of
iterating over commit-graphs along their `->base_graph` pointers.

This further prepares us to consolidate the progress output of `git
commit-graph verify`.

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 e84692093537f1a7c9e7305eb7c62e914f2c0add..bb56733d8c35e60095780c0781ba1dd77177d309 100644 (file)
@@ -2708,10 +2708,11 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
                return 1;
        }
 
-       local_error = verify_one_commit_graph(r, g, flags);
-
-       if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW) && g->base_graph)
-               local_error |= verify_commit_graph(r, g->base_graph, flags);
+       for (; g; g = g->base_graph) {
+               local_error |= verify_one_commit_graph(r, g, flags);
+               if (flags & COMMIT_GRAPH_VERIFY_SHALLOW)
+                       break;
+       }
 
        return local_error;
 }