From: Patrick Steinhardt Date: Mon, 16 Nov 2026 13:07:39 GMT Subject: [PATCH 03/12] commit-graph: expose function to validate a commit graph chain Message-ID: <20261116-pks-odb-pluggable-commit-graphs-v1-3-a83fc1ff0808@pks.im> In-Reply-To: <20261116-pks-odb-pluggable-commit-graphs-v1-0-a83fc1ff0808@pks.im> When we have loaded a commit graph chain we need to validate whether all of its layers have been written with compatible settings. If that's not the case, then some functionality of the chain needs to be restricted as it would otherwise yield inconsistent results. In a subsequent commit we'll move loading of commit graphs into the object database backend, and consequently the backend will have to perform this validation. Expose this functionality to prepare for this. Signed-off-by: Patrick Steinhardt --- commit-graph.c | 9 +++++++-- commit-graph.h | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/commit-graph.c b/commit-graph.c index c427a6f90f7..9464522feb5 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -574,6 +574,12 @@ static void validate_mixed_bloom_settings(struct commit_graph *g) } } +void commit_graph_validate_chain(struct commit_graph *g) +{ + validate_mixed_generation_chain(g); + validate_mixed_bloom_settings(g); +} + int commit_graph_link_base(struct commit_graph *g, struct commit_graph *base) { @@ -695,8 +701,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct object_database *odb, } } - validate_mixed_generation_chain(graph_chain); - validate_mixed_bloom_settings(graph_chain); + commit_graph_validate_chain(graph_chain); fclose(fp); strbuf_release(&line); diff --git a/commit-graph.h b/commit-graph.h index 8660c7fe698..dc4f6194c72 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -134,6 +134,13 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct object_database *odb, */ int commit_graph_link_base(struct commit_graph *g, struct commit_graph *base); + +/* + * Validate the chain of commit graph layers to ensure that all layers are + * compatible with one another. This may disable generation data and Bloom + * filters in case they aren't. + */ +void commit_graph_validate_chain(struct commit_graph *g); struct commit_graph *read_commit_graph_one(struct repository *repo, const char *dir); -- 2.56.1.763.g16177fe143.dirty