Re: [PATCH v6 3/4] commit-graph: export prepare_commit_graph()
From: Patrick Steinhardt <hidden>
Date: 2025-07-31 06:42:51
On Wed, Jul 30, 2025 at 07:55:09PM +0200, Toon Claes wrote:
Allow users of the commit-graph to explicitly prepare the commit-graph. This can be useful when users want to start using bloom keys before calling functions like prepare_revision_walk(). We'll use this exported function in a subsequent commit.
Hm. Ideally we wouldn't have to expose this low-level function and the commit-graph subsystem would know to handle this. We typically have patterns like this in our codebase: if (repo_find_commit_pos_in_graph(r, c, &graph_pos)) load_bloom_filter_from_graph(r->objects->commit_graph, filter, graph_pos); The call to `repo_find_commit_pos_in_graph()` knows to call `prepare_commit_graph()`, so no manual call to that function would be required. I haven't yet read the next commit though that adds the callsite. So let's read on.
quoted hunk ↗ jump to hunk
diff --git a/commit-graph.h b/commit-graph.h index 78ab7b875b..0f76681333 100644 --- a/commit-graph.h +++ b/commit-graph.h@@ -131,6 +131,14 @@ struct repo_settings; struct commit_graph *parse_commit_graph(struct repo_settings *s, void *graph_map, size_t graph_size); +/* + * Return 1 if commit_graph is non-NULL, and 0 otherwise. + * + * On the first invocation, this function attempts to load the commit + * graph if the_repository is configured to have one. + */ +int prepare_commit_graph(struct repository *r);
Let's fix the reference to `the_repository` while at it. Patrick