Skip to content

Commit eb319d6

Browse files
ttaylorrgitster
authored andcommitted
commit-graph.c: extract verify_one_commit_graph()
When the `verify_commit_graph()` function was extended to support commit-graph chains via 3da4b60 (commit-graph: verify chains with --shallow mode, 2019-06-18), it did so by recursively calling itself on each layer of the commit-graph chain. In practice this poses no issues, since commit-graph chains do not loop, and there are few enough of them that adding additional frames to the stack is not a problem. A future commit will consolidate the progress output from `git commit-graph verify` when verifying chained commit-graphs to print a single line instead of one progress meter per commit-graph layer. Prepare for this by extracting a routine to verify a single layer of a commit-graph. Note that `verify_commit_graph()` is still recursive after this patch, but this will change in the subsequent patch. Signed-off-by: Taylor Blau <[email protected]> Acked-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 39bdd30 commit eb319d6

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

commit-graph.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,18 +2543,14 @@ static int commit_graph_checksum_valid(struct commit_graph *g)
25432543
return hashfile_checksum_valid(g->data, g->data_len);
25442544
}
25452545

2546-
int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2546+
static int verify_one_commit_graph(struct repository *r,
2547+
struct commit_graph *g,
2548+
int flags)
25472549
{
25482550
uint32_t i, cur_fanout_pos = 0;
25492551
struct object_id prev_oid, cur_oid;
25502552
int generation_zero = 0;
25512553
struct progress *progress = NULL;
2552-
int local_error = 0;
2553-
2554-
if (!g) {
2555-
graph_report("no commit-graph file loaded");
2556-
return 1;
2557-
}
25582554

25592555
verify_commit_graph_error = verify_commit_graph_lite(g);
25602556
if (verify_commit_graph_error)
@@ -2700,7 +2696,19 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
27002696
}
27012697
stop_progress(&progress);
27022698

2703-
local_error = verify_commit_graph_error;
2699+
return verify_commit_graph_error;
2700+
}
2701+
2702+
int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2703+
{
2704+
int local_error = 0;
2705+
2706+
if (!g) {
2707+
graph_report("no commit-graph file loaded");
2708+
return 1;
2709+
}
2710+
2711+
local_error = verify_one_commit_graph(r, g, flags);
27042712

27052713
if (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW) && g->base_graph)
27062714
local_error |= verify_commit_graph(r, g->base_graph, flags);

0 commit comments

Comments
 (0)