From: Patrick Steinhardt Date: Wed, 04 Nov 2026 15:57:23 GMT Subject: [PATCH 01/10] commit-graph: rename `struct commit_graph_opts` Message-ID: <20261104-pks-commit-graph-write-refactorings-v1-1-d013d9401a59@pks.im> In-Reply-To: <20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im> The `struct commit_graph_opts` is used by us to control how exactly a commit graph gets written. Nothing really indicates that it's only intended for use by `write_commit_graph()` though. Rename it to `struct commit_graph_write_options` to fix that. Note that in a subsequent commit we'll also rename `write_commit_graph()` to `commit_graph_write()` to match our modern best practices for naming, and that will align the naming for both of these. While at it, also introduce an `INIT` macro. Signed-off-by: Patrick Steinhardt --- builtin/commit-graph.c | 7 ++----- commit-graph.c | 6 +++--- commit-graph.h | 11 ++++++++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 4d28a9d51ec..0445302ba8b 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -141,7 +141,7 @@ static int cmd_commit_graph_verify(int argc, } struct commit_graph_write_config_data { - struct commit_graph_opts *write_opts; + struct commit_graph_write_options *write_opts; struct opts_commit_graph *opts; }; @@ -229,10 +229,7 @@ static int cmd_commit_graph_write(int argc, const char *prefix, struct repository *repo) { - struct commit_graph_opts write_opts = { - .size_multiple = 2, - .max_new_filters = -1, - }; + struct commit_graph_write_options write_opts = COMMIT_GRAPH_WRITE_OPTIONS_INIT; struct opts_commit_graph opts = { .progress = isatty(2), .enable_changed_paths = -1, diff --git a/commit-graph.c b/commit-graph.c index 6c141a6555f..2f9bf7a44fd 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -1166,7 +1166,7 @@ struct write_commit_graph_context { trust_generation_numbers:1; struct topo_level_slab *topo_levels; - const struct commit_graph_opts *opts; + const struct commit_graph_write_options *opts; size_t total_bloom_filter_data_size; const struct bloom_filter_settings *bloom_settings; @@ -1916,7 +1916,7 @@ static int add_ref_to_set(const struct reference *ref, void *cb_data) int write_commit_graph_reachable(struct repository *repo, const char *dir, enum commit_graph_write_flags flags, - const struct commit_graph_opts *opts) + const struct commit_graph_write_options *opts) { struct oidset commits = OIDSET_INIT; struct refs_cb_data data; @@ -2565,7 +2565,7 @@ int write_commit_graph(struct repository *r, const struct string_list *const pack_indexes, struct oidset *commits, enum commit_graph_write_flags flags, - const struct commit_graph_opts *opts) + const struct commit_graph_write_options *opts) { struct write_commit_graph_context ctx = { .r = r, diff --git a/commit-graph.h b/commit-graph.h index 3b55192c2a1..513713ecb62 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -168,7 +168,7 @@ enum commit_graph_split_flags { COMMIT_GRAPH_SPLIT_REPLACE = 2 }; -struct commit_graph_opts { +struct commit_graph_write_options { int size_multiple; int max_commits; timestamp_t expire_time; @@ -176,6 +176,11 @@ struct commit_graph_opts { int max_new_filters; }; +#define COMMIT_GRAPH_WRITE_OPTIONS_INIT { \ + .size_multiple = 2, \ + .max_new_filters = -1, \ +} + /* * The write_commit_graph* methods return zero on success * and a negative value on failure. Note that if the repository @@ -189,13 +194,13 @@ struct commit_graph_opts { int write_commit_graph_reachable(struct repository *repo, const char *dir, enum commit_graph_write_flags flags, - const struct commit_graph_opts *opts); + const struct commit_graph_write_options *opts); int write_commit_graph(struct repository *r, const char *dir, const struct string_list *pack_indexes, struct oidset *commits, enum commit_graph_write_flags flags, - const struct commit_graph_opts *opts); + const struct commit_graph_write_options *opts); #define COMMIT_GRAPH_VERIFY_SHALLOW (1 << 0) -- 2.56.0.500.g5d06dc02cd.dirty