{"thread":{"id":"66772","subject":"[PATCH 00/10] commit-graph: several refactorings for writing commit graphs","startedAt":"2026-11-04T15:57:22Z","lastAt":"2026-11-05T15:33:26Z","messageCount":22,"participants":["Patrick Steinhardt","Derrick Stolee","Kristofer Karlsson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":10},"messages":[{"id":"557448","messageId":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","threadId":"66772","inReplyTo":null,"subject":"[PATCH 00/10] commit-graph: several refactorings for writing commit graphs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:22Z","receivedAt":"2026-11-04T15:57:22Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nthis patch series includes several small cleanups for the interfaces for\nwriting commit graphs. Most importantly, the series refactors options so\nthat they all get passed via `struct commit_graph_write_options`. These\ncleanups are split out of a bigger change to make reading and writing\ncommit-graphs pluggable via the object database bakcend.\n\nThe series is based on 750f5de7dfe (The 14th batch, 2026-11-03) with\nps/commit-graph-cleanups at cdc7d6b46c6 (builtin/commit-graph:\nde-globalize options handling, 2026-10-28) merged into it.\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (10):\n      commit-graph: rename `struct commit_graph_opts`\n      commit-graph: pass writer flags via options\n      commit-graph: drop `NULL` checks for write options\n      commit-graph: drop redundant flags in write context\n      commit-graph: merge the two commit graph writers\n      commit-graph: move remaining write parameters into options\n      commit-graph: fix mixup of write/verify flags\n      builtin/commit-graph: set flags directly\n      odb/source-files: verify commit-graphs as part of fsck\n      commit-graph: modernize function names\n\n Documentation/gitformat-chunk.adoc |   2 +-\n builtin/commit-graph.c             |  82 ++++++-----------\n builtin/fetch.c                    |  23 ++---\n builtin/fsck.c                     |  20 ----\n builtin/gc.c                       |  15 ++-\n commit-graph.c                     | 183 +++++++++++++++++--------------------\n commit-graph.h                     |  40 ++++----\n odb.c                              |   2 +-\n odb/source-files.c                 |  25 +++++\n oss-fuzz/fuzz-commit-graph.c       |   4 +-\n t/helper/test-read-graph.c         |   2 +-\n 11 files changed, 183 insertions(+), 215 deletions(-)\n\n\n---\nbase-commit: d00aeacdaa9e157548863b0eecc019044126c621\nchange-id: 20261103-pks-commit-graph-write-refactorings-f68fb22efd9b\n\n\n"},{"id":"557449","messageId":"20261104-pks-commit-graph-write-refactorings-v1-1-d013d9401a59@pks.im","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"[PATCH 01/10] commit-graph: rename `struct commit_graph_opts`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:23Z","receivedAt":"2026-11-04T15:57:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The `struct commit_graph_opts` is used by us to control how exactly a\ncommit graph gets written. Nothing really indicates that it's only\nintended for use by `write_commit_graph()` though.\n\nRename it to `struct commit_graph_write_options` to fix that. Note that\nin a subsequent commit we'll also rename `write_commit_graph()` to\n`commit_graph_write()` to match our modern best practices for naming,\nand that will align the naming for both of these.\n\nWhile at it, also introduce an `INIT` macro.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c |  7 ++-----\n commit-graph.c         |  6 +++---\n commit-graph.h         | 11 ++++++++---\n 3 files changed, 13 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 4d28a9d51ec..0445302ba8b 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -141,7 +141,7 @@ static int cmd_commit_graph_verify(int argc,\n }\n \n struct commit_graph_write_config_data {\n-\tstruct commit_graph_opts *write_opts;\n+\tstruct commit_graph_write_options *write_opts;\n \tstruct opts_commit_graph *opts;\n };\n \n@@ -229,10 +229,7 @@ static int cmd_commit_graph_write(int argc,\n \t\t\t\t  const char *prefix,\n \t\t\t\t  struct repository *repo)\n {\n-\tstruct commit_graph_opts write_opts = {\n-\t\t.size_multiple = 2,\n-\t\t.max_new_filters = -1,\n-\t};\n+\tstruct commit_graph_write_options write_opts = COMMIT_GRAPH_WRITE_OPTIONS_INIT;\n \tstruct opts_commit_graph opts = {\n \t\t.progress = isatty(2),\n \t\t.enable_changed_paths = -1,\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 6c141a6555f..2f9bf7a44fd 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1166,7 +1166,7 @@ struct write_commit_graph_context {\n \t\t trust_generation_numbers:1;\n \n \tstruct topo_level_slab *topo_levels;\n-\tconst struct commit_graph_opts *opts;\n+\tconst struct commit_graph_write_options *opts;\n \tsize_t total_bloom_filter_data_size;\n \tconst struct bloom_filter_settings *bloom_settings;\n \n@@ -1916,7 +1916,7 @@ static int add_ref_to_set(const struct reference *ref, void *cb_data)\n int write_commit_graph_reachable(struct repository *repo,\n \t\t\t\t const char *dir,\n \t\t\t\t enum commit_graph_write_flags flags,\n-\t\t\t\t const struct commit_graph_opts *opts)\n+\t\t\t\t const struct commit_graph_write_options *opts)\n {\n \tstruct oidset commits = OIDSET_INIT;\n \tstruct refs_cb_data data;\n@@ -2565,7 +2565,7 @@ int write_commit_graph(struct repository *r,\n \t\t       const struct string_list *const pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\n-\t\t       const struct commit_graph_opts *opts)\n+\t\t       const struct commit_graph_write_options *opts)\n {\n \tstruct write_commit_graph_context ctx = {\n \t\t.r = r,\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 3b55192c2a1..513713ecb62 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -168,7 +168,7 @@ enum commit_graph_split_flags {\n \tCOMMIT_GRAPH_SPLIT_REPLACE          = 2\n };\n \n-struct commit_graph_opts {\n+struct commit_graph_write_options {\n \tint size_multiple;\n \tint max_commits;\n \ttimestamp_t expire_time;\n@@ -176,6 +176,11 @@ struct commit_graph_opts {\n \tint max_new_filters;\n };\n \n+#define COMMIT_GRAPH_WRITE_OPTIONS_INIT { \\\n+\t.size_multiple = 2, \\\n+\t.max_new_filters = -1, \\\n+}\n+\n /*\n  * The write_commit_graph* methods return zero on success\n  * and a negative value on failure. Note that if the repository\n@@ -189,13 +194,13 @@ struct commit_graph_opts {\n int write_commit_graph_reachable(struct repository *repo,\n \t\t\t\t const char *dir,\n \t\t\t\t enum commit_graph_write_flags flags,\n-\t\t\t\t const struct commit_graph_opts *opts);\n+\t\t\t\t const struct commit_graph_write_options *opts);\n int write_commit_graph(struct repository *r,\n \t\t       const char *dir,\n \t\t       const struct string_list *pack_indexes,\n \t\t       struct oidset *commits,\n \t\t       enum commit_graph_write_flags flags,\n-\t\t       const struct commit_graph_opts *opts);\n+\t\t       const struct commit_graph_write_options *opts);\n \n #define COMMIT_GRAPH_VERIFY_SHALLOW\t(1 << 0)\n \n\n-- \n2.56.0.500.g5d06dc02cd.dirty\n\n\n"},{"id":"557450","messageId":"20261104-pks-commit-graph-write-refactorings-v1-2-d013d9401a59@pks.im","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"[PATCH 02/10] commit-graph: pass writer flags via options","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:24Z","receivedAt":"2026-11-04T15:57:24Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"While we already accept an options structure when writing commit graphs,\nwe expect the caller to also pass a couple of other optional parameters\nthat control how exactly we perform the write. This mix is somewhat\narbitrary though and makes for an awkward calling convention, where it\nis not immediately obvious which parameters are required and which are\noptions.\n\nAs a first step, move flags into the options structure and adapt callers\naccordingly. The other parameters will follow in subsequent commits.\n\nNote that with this change, passing the options structure now becomes\nmandatory. This isn't much of an issue though because all callers do in\nfact pass one now.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c | 14 ++++++--------\n builtin/fetch.c        | 11 +++++------\n builtin/gc.c           | 12 ++++++++----\n commit-graph.c         | 24 +++++++++++-------------\n commit-graph.h         |  3 +--\n 5 files changed, 31 insertions(+), 33 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 0445302ba8b..d49faf543b4 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -243,7 +243,6 @@ static int cmd_commit_graph_write(int argc,\n \tstruct oidset commits = OIDSET_INIT;\n \tstruct odb_files_dir *dir = NULL;\n \tint result = 0;\n-\tenum commit_graph_write_flags flags = 0;\n \tstruct progress *progress = NULL;\n \tstruct option options[] = {\n \t\tOPT_BOOL(0, \"reachable\", &opts.reachable,\n@@ -290,23 +289,23 @@ static int cmd_commit_graph_write(int argc,\n \tif (!opts.obj_dir)\n \t\topts.obj_dir = repo_get_object_directory(repo);\n \tif (opts.append)\n-\t\tflags |= COMMIT_GRAPH_WRITE_APPEND;\n+\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_APPEND;\n \tif (opts.split)\n-\t\tflags |= COMMIT_GRAPH_WRITE_SPLIT;\n+\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_SPLIT;\n \tif (opts.progress)\n-\t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n+\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \tif (!opts.enable_changed_paths)\n-\t\tflags |= COMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS;\n+\t\twrite_opts.flags |= COMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS;\n \tif (opts.enable_changed_paths == 1 ||\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n-\t\tflags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n+\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n \tdir = odb_source_files_find_dir(repo->objects, opts.obj_dir);\n \tif (!dir)\n \t\tdie(_(\"could not find object directory matching %s\"), opts.obj_dir);\n \n \tif (opts.reachable) {\n-\t\tif (write_commit_graph_reachable(repo, dir->abspath, flags, &write_opts))\n+\t\tif (write_commit_graph_reachable(repo, dir->abspath, &write_opts))\n \t\t\tresult = 1;\n \t\tgoto cleanup;\n \t}\n@@ -346,7 +345,6 @@ static int cmd_commit_graph_write(int argc,\n \tif (write_commit_graph(repo, dir->abspath,\n \t\t\t       opts.stdin_packs ? &pack_indexes : NULL,\n \t\t\t       opts.stdin_commits ? &commits : NULL,\n-\t\t\t       flags,\n \t\t\t       &write_opts))\n \t\tresult = 1;\n \ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 09966e5ce8d..b76e7725728 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2936,10 +2936,11 @@ int cmd_fetch(int argc,\n \tif (fetch_write_commit_graph > 0 ||\n \t    (fetch_write_commit_graph < 0 &&\n \t     the_repository->settings.fetch_write_commit_graph)) {\n-\t\tint commit_graph_flags = COMMIT_GRAPH_WRITE_SPLIT;\n+\t\tstruct commit_graph_write_options write_opts = COMMIT_GRAPH_WRITE_OPTIONS_INIT;\n \n+\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_SPLIT;\n \t\tif (progress)\n-\t\t\tcommit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n+\t\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n \t\tif (graph_write_mode != GRAPH_WRITE_SKIP) {\n \t\t\ttrace2_region_enter(\"fetch\", \"write-commit-graph\",\n@@ -2948,13 +2949,11 @@ int cmd_fetch(int argc,\n \t\t\t\twrite_commit_graph(\n \t\t\t\t\tthe_repository,\n \t\t\t\t\tthe_repository->objects->source->path,\n-\t\t\t\t\tNULL, &updated_tips,\n-\t\t\t\t\tcommit_graph_flags, NULL);\n+\t\t\t\t\tNULL, &updated_tips, &write_opts);\n \t\t\telse\n \t\t\t\twrite_commit_graph_reachable(\n \t\t\t\t\tthe_repository,\n-\t\t\t\t\tthe_repository->objects->source->path,\n-\t\t\t\t\tcommit_graph_flags, NULL);\n+\t\t\t\t\tthe_repository->objects->source->path, &write_opts);\n \t\t\ttrace2_region_leave(\"fetch\", \"write-commit-graph\",\n \t\t\t\t\t    the_repository);\n \t\t}\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 81cecf6b6c3..a157909ed54 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -734,11 +734,15 @@ int cmd_gc(int argc,\n \t\tclean_pack_garbage();\n \t}\n \n-\tif (the_repository->settings.gc_write_commit_graph == 1)\n+\tif (the_repository->settings.gc_write_commit_graph == 1) {\n+\t\tstruct commit_graph_write_options write_opts = COMMIT_GRAPH_WRITE_OPTIONS_INIT;\n+\n+\t\tif (!opts.quiet && !daemonized)\n+\t\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n+\n \t\twrite_commit_graph_reachable(the_repository,\n-\t\t\t\t\t     the_repository->objects->source->path,\n-\t\t\t\t\t     !opts.quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,\n-\t\t\t\t\t     NULL);\n+\t\t\t\t\t     the_repository->objects->source->path, &write_opts);\n+\t}\n \n \tif (!daemonized) {\n \t\tchar *path = repo_git_path(the_repository, \"gc.log\");\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 2f9bf7a44fd..9216d051c1f 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -32,14 +32,15 @@\n \n void git_test_write_commit_graph_or_die(struct repository *repo)\n {\n-\tint flags = 0;\n+\tstruct commit_graph_write_options opts = COMMIT_GRAPH_WRITE_OPTIONS_INIT;\n+\n \tif (!git_env_bool(GIT_TEST_COMMIT_GRAPH, 0))\n \t\treturn;\n \n \tif (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n-\t\tflags = COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n+\t\topts.flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tif (write_commit_graph_reachable(repo, repo->objects->source->path, flags, NULL))\n+\tif (write_commit_graph_reachable(repo, repo->objects->source->path, &opts))\n \t\tdie(\"failed to write commit-graph under GIT_TEST_COMMIT_GRAPH\");\n }\n \n@@ -1915,7 +1916,6 @@ static int add_ref_to_set(const struct reference *ref, void *cb_data)\n \n int write_commit_graph_reachable(struct repository *repo,\n \t\t\t\t const char *dir,\n-\t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_write_options *opts)\n {\n \tstruct oidset commits = OIDSET_INIT;\n@@ -1926,7 +1926,7 @@ int write_commit_graph_reachable(struct repository *repo,\n \tdata.repo = repo;\n \tdata.commits = &commits;\n \n-\tif (flags & COMMIT_GRAPH_WRITE_PROGRESS)\n+\tif (opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tdata.progress = start_delayed_progress(\n \t\t\trepo,\n \t\t\t_(\"Collecting referenced commits\"), 0);\n@@ -1936,8 +1936,7 @@ int write_commit_graph_reachable(struct repository *repo,\n \n \tstop_progress(&data.progress);\n \n-\tresult = write_commit_graph(repo, dir, NULL, &commits,\n-\t\t\t\t    flags, opts);\n+\tresult = write_commit_graph(repo, dir, NULL, &commits, opts);\n \n \toidset_clear(&commits);\n \treturn result;\n@@ -2564,14 +2563,13 @@ int write_commit_graph(struct repository *r,\n \t\t       const char *dir,\n \t\t       const struct string_list *const pack_indexes,\n \t\t       struct oidset *commits,\n-\t\t       enum commit_graph_write_flags flags,\n \t\t       const struct commit_graph_write_options *opts)\n {\n \tstruct write_commit_graph_context ctx = {\n \t\t.r = r,\n-\t\t.append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0,\n-\t\t.report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0,\n-\t\t.split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,\n+\t\t.append = opts->flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0,\n+\t\t.report_progress = opts->flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0,\n+\t\t.split = opts->flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,\n \t\t.opts = opts,\n \t\t.total_bloom_filter_data_size = 0,\n \t\t.write_generation_data = (get_configured_generation_version(r) == 2),\n@@ -2617,9 +2615,9 @@ int write_commit_graph(struct repository *r,\n \tfor (struct commit_graph *chain = g; chain; chain = chain->base_graph)\n \t\tchain->topo_levels = &topo_levels;\n \n-\tif (flags & COMMIT_GRAPH_WRITE_BLOOM_FILTERS)\n+\tif (opts->flags & COMMIT_GRAPH_WRITE_BLOOM_FILTERS)\n \t\tctx.changed_paths = 1;\n-\tif (!(flags & COMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS)) {\n+\tif (!(opts->flags & COMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS)) {\n \t\t/* We have changed-paths already. Keep them in the next graph */\n \t\tif (g && g->bloom_filter_settings) {\n \t\t\tctx.changed_paths = 1;\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 513713ecb62..7461093a990 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -169,6 +169,7 @@ enum commit_graph_split_flags {\n };\n \n struct commit_graph_write_options {\n+\tenum commit_graph_write_flags flags;\n \tint size_multiple;\n \tint max_commits;\n \ttimestamp_t expire_time;\n@@ -193,13 +194,11 @@ struct commit_graph_write_options {\n  */\n int write_commit_graph_reachable(struct repository *repo,\n \t\t\t\t const char *dir,\n-\t\t\t\t enum commit_graph_write_flags flags,\n \t\t\t\t const struct commit_graph_write_options *opts);\n int write_commit_graph(struct repository *r,\n \t\t       const char *dir,\n \t\t       const struct string_list *pack_indexes,\n \t\t       struct oidset *commits,\n-\t\t       enum commit_graph_write_flags flags,\n \t\t       const struct commit_graph_write_options *opts);\n \n #define COMMIT_GRAPH_VERIFY_SHALLOW\t(1 << 0)\n\n-- \n2.56.0.500.g5d06dc02cd.dirty\n\n\n"},{"id":"557451","messageId":"20261104-pks-commit-graph-write-refactorings-v1-3-d013d9401a59@pks.im","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"[PATCH 03/10] commit-graph: drop `NULL` checks for write options","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:25Z","receivedAt":"2026-11-04T15:57:25Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The commit-graph writer still handles the case where `ctx->opts` is not\nset by falling back to defaults sprinkled across several functions. But\nsince we have moved the write flags into the options structure in the\npreceding commit all callers pass it, and we can thus start to treat it\nas a mandatory parameter now.\n\nDrop the checks and use the options unconditionally.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n commit-graph.c | 30 ++++++++++--------------------\n 1 file changed, 10 insertions(+), 20 deletions(-)\n\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 9216d051c1f..e86569b7ced 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1568,8 +1568,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n {\n \tint i;\n \tstruct commit *commit;\n-\tenum commit_graph_split_flags flags = ctx->opts ?\n-\t\tctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;\n+\tenum commit_graph_split_flags flags = ctx->opts->split_flags;\n \n \tif (ctx->report_progress)\n \t\tctx->progress = start_delayed_progress(\n@@ -1858,7 +1857,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)\n \telse\n \t\tQSORT(sorted_commits, ctx->commits.nr, commit_gen_cmp);\n \n-\tmax_new_filters = ctx->opts && ctx->opts->max_new_filters >= 0 ?\n+\tmax_new_filters = ctx->opts->max_new_filters >= 0 ?\n \t\tctx->opts->max_new_filters : ctx->commits.nr;\n \n \tfor (i = 0; i < ctx->commits.nr; i++) {\n@@ -2035,8 +2034,7 @@ static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx)\n static void copy_oids_to_commits(struct write_commit_graph_context *ctx)\n {\n \tuint32_t i;\n-\tenum commit_graph_split_flags flags = ctx->opts ?\n-\t\tctx->opts->split_flags : COMMIT_GRAPH_SPLIT_UNSPECIFIED;\n+\tenum commit_graph_split_flags flags = ctx->opts->split_flags;\n \n \tctx->num_extra_edges = 0;\n \tif (ctx->report_progress)\n@@ -2290,20 +2288,13 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx,\n {\n \tstruct commit_graph *g;\n \tuint32_t num_commits;\n-\tenum commit_graph_split_flags flags = COMMIT_GRAPH_SPLIT_UNSPECIFIED;\n-\tuint32_t i;\n-\n-\tint max_commits = 0;\n+\tenum commit_graph_split_flags flags = ctx->opts->split_flags;\n+\tint max_commits = ctx->opts->max_commits;\n \tint size_mult = 2;\n+\tuint32_t i;\n \n-\tif (ctx->opts) {\n-\t\tmax_commits = ctx->opts->max_commits;\n-\n-\t\tif (ctx->opts->size_multiple)\n-\t\t\tsize_mult = ctx->opts->size_multiple;\n-\n-\t\tflags = ctx->opts->split_flags;\n-\t}\n+\tif (ctx->opts->size_multiple)\n+\t\tsize_mult = ctx->opts->size_multiple;\n \n \tg = graph_to_merge;\n \tnum_commits = ctx->commits.nr;\n@@ -2508,7 +2499,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tsize_t dirnamelen;\n \ttimestamp_t expire_time = time(NULL);\n \n-\tif (ctx->opts && ctx->opts->expire_time)\n+\tif (ctx->opts->expire_time)\n \t\texpire_time = ctx->opts->expire_time;\n \tif (!ctx->split) {\n \t\tchar *chain_file_name = get_commit_graph_chain_filename(ctx->dir);\n@@ -2645,8 +2636,7 @@ int write_commit_graph(struct repository *r,\n \t\t\t\tctx.commit_graph_filenames_before[--i] = xstrdup(chain->filename);\n \t\t}\n \n-\t\tif (ctx.opts)\n-\t\t\treplace = ctx.opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;\n+\t\treplace = ctx.opts->split_flags & COMMIT_GRAPH_SPLIT_REPLACE;\n \t}\n \n \tif (odb_count_objects(r->objects, ODB_COUNT_OBJECTS_APPROXIMATE, &ctx.approx_nr_objects) < 0)\n\n-- \n2.56.0.500.g5d06dc02cd.dirty\n\n\n"},{"id":"557452","messageId":"20261104-pks-commit-graph-write-refactorings-v1-4-d013d9401a59@pks.im","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"[PATCH 04/10] commit-graph: drop redundant flags in write context","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:26Z","receivedAt":"2026-11-04T15:57:26Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"In the preceding commit we have moved the flags that control how we\nwrite a commit graph into its options structure. As a consequence we\nhave those flags implicitly available in the write context, too, as it\nalready contains a pointer to the options struct. This makes a couple of\nindividual flags that we track in the write context redundant as they\nare a simple alias of the flags.\n\nDrop these redundant flags.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n commit-graph.c | 61 ++++++++++++++++++++++++++++------------------------------\n 1 file changed, 29 insertions(+), 32 deletions(-)\n\ndiff --git a/commit-graph.c b/commit-graph.c\nindex e86569b7ced..4f3563f4d0b 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -1158,10 +1158,7 @@ struct write_commit_graph_context {\n \tuint32_t new_num_commits_in_base;\n \tstruct commit_graph *new_base_graph;\n \n-\tunsigned append:1,\n-\t\t report_progress:1,\n-\t\t split:1,\n-\t\t changed_paths:1,\n+\tunsigned changed_paths:1,\n \t\t order_by_pack:1,\n \t\t write_generation_data:1,\n \t\t trust_generation_numbers:1;\n@@ -1570,7 +1567,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n \tstruct commit *commit;\n \tenum commit_graph_split_flags flags = ctx->opts->split_flags;\n \n-\tif (ctx->report_progress)\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tctx->progress = start_delayed_progress(\n \t\t\t\t\tctx->r,\n \t\t\t\t\t_(\"Loading known commits in commit graph\"),\n@@ -1588,7 +1585,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n \t * than the number of missing commits in the reachable\n \t * closure.\n \t */\n-\tif (ctx->report_progress)\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tctx->progress = start_delayed_progress(\n \t\t\t\t\tctx->r,\n \t\t\t\t\t_(\"Expanding reachable commits in commit graph\"),\n@@ -1599,7 +1596,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n \n \t\tif (!commit)\n \t\t\tcontinue;\n-\t\tif (ctx->split) {\n+\t\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_SPLIT) {\n \t\t\tif ((!repo_parse_commit(ctx->r, commit) &&\n \t\t\t     commit_graph_position(commit) == COMMIT_NOT_FROM_GRAPH) ||\n \t\t\t    flags == COMMIT_GRAPH_SPLIT_REPLACE)\n@@ -1609,7 +1606,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)\n \t}\n \tstop_progress(&ctx->progress);\n \n-\tif (ctx->report_progress)\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tctx->progress = start_delayed_progress(\n \t\t\t\t\tctx->r,\n \t\t\t\t\t_(\"Clearing commit marks in commit graph\"),\n@@ -1731,7 +1728,7 @@ static void compute_topological_levels(struct write_commit_graph_context *ctx)\n \t\t.data = ctx,\n \t};\n \n-\tif (ctx->report_progress)\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tinfo.progress = ctx->progress\n \t\t\t      = start_delayed_progress(\n \t\t\t\t\tctx->r,\n@@ -1766,7 +1763,7 @@ static void compute_generation_numbers(struct write_commit_graph_context *ctx)\n \t\t.set_generation = set_generation_v2,\n \t};\n \n-\tif (ctx->report_progress)\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tinfo.progress = ctx->progress\n \t\t\t      = start_delayed_progress(\n \t\t\t\t\tctx->r,\n@@ -1844,7 +1841,7 @@ static void compute_bloom_filters(struct write_commit_graph_context *ctx)\n \n \tinit_bloom_filters();\n \n-\tif (ctx->report_progress)\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tprogress = start_delayed_progress(\n \t\t\tctx->r,\n \t\t\t_(\"Computing commit changed paths Bloom filters\"),\n@@ -1948,7 +1945,7 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,\n \tstruct strbuf progress_title = STRBUF_INIT;\n \tint ret = 0;\n \n-\tif (ctx->report_progress) {\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS) {\n \t\tstrbuf_addf(&progress_title,\n \t\t\t    Q_(\"Finding commits for commit graph in %\"PRIuMAX\" pack\",\n \t\t\t       \"Finding commits for commit graph in %\"PRIuMAX\" packs\",\n@@ -2014,7 +2011,7 @@ static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx)\n \t\t.typep = &type,\n \t};\n \n-\tif (ctx->report_progress)\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tctx->progress = start_delayed_progress(\n \t\t\tctx->r,\n \t\t\t_(\"Finding commits for commit graph among packed objects\"),\n@@ -2037,7 +2034,7 @@ static void copy_oids_to_commits(struct write_commit_graph_context *ctx)\n \tenum commit_graph_split_flags flags = ctx->opts->split_flags;\n \n \tctx->num_extra_edges = 0;\n-\tif (ctx->report_progress)\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tctx->progress = start_delayed_progress(\n \t\t\tctx->r,\n \t\t\t_(\"Finding extra edges in commit graph\"),\n@@ -2051,11 +2048,13 @@ static void copy_oids_to_commits(struct write_commit_graph_context *ctx)\n \n \t\tcommit = lookup_commit(ctx->r, &ctx->oids.oid[i]);\n \n-\t\tif (ctx->split && flags != COMMIT_GRAPH_SPLIT_REPLACE &&\n+\t\tif ((ctx->opts->flags & COMMIT_GRAPH_WRITE_SPLIT) &&\n+\t\t    flags != COMMIT_GRAPH_SPLIT_REPLACE &&\n \t\t    commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH)\n \t\t\tcontinue;\n \n-\t\tif (ctx->split && flags == COMMIT_GRAPH_SPLIT_REPLACE)\n+\t\tif ((ctx->opts->flags & COMMIT_GRAPH_WRITE_SPLIT) &&\n+\t\t    flags == COMMIT_GRAPH_SPLIT_REPLACE)\n \t\t\trepo_parse_commit(ctx->r, commit);\n \t\telse\n \t\t\trepo_parse_commit_no_graph(ctx->r, commit);\n@@ -2100,14 +2099,14 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n {\n \tuint32_t i;\n \tstruct hashfile *f;\n-\tstruct tempfile *graph_layer; /* when ctx->split is non-zero */\n+\tstruct tempfile *graph_layer; /* when COMMIT_GRAPH_WRITE_SPLIT is non-zero */\n \tstruct lock_file lk = LOCK_INIT;\n \tconst unsigned hashsz = ctx->r->hash_algo->rawsz;\n \tstruct strbuf progress_title = STRBUF_INIT;\n \tstruct chunkfile *cf;\n \tunsigned char file_hash[GIT_MAX_RAWSZ];\n \n-\tif (ctx->split) {\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_SPLIT) {\n \t\tstruct strbuf tmp_file = STRBUF_INIT;\n \n \t\tstrbuf_addf(&tmp_file,\n@@ -2124,7 +2123,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t\treturn -1;\n \t}\n \n-\tif (ctx->split) {\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_SPLIT) {\n \t\tchar *lock_name = get_commit_graph_chain_filename(ctx->dir);\n \n \t\trepo_hold_lock_file_for_update_mode(ctx->r, &lk, lock_name,\n@@ -2195,7 +2194,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \thashwrite_u8(f, get_num_chunks(cf));\n \thashwrite_u8(f, ctx->num_commit_graphs_after - 1);\n \n-\tif (ctx->report_progress) {\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS) {\n \t\tstrbuf_addf(&progress_title,\n \t\t\t    Q_(\"Writing out commit graph in %d pass\",\n \t\t\t       \"Writing out commit graph in %d passes\",\n@@ -2212,7 +2211,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \tstop_progress(&ctx->progress);\n \tstrbuf_release(&progress_title);\n \n-\tif (ctx->split && ctx->base_graph_name && ctx->num_commit_graphs_after > 1) {\n+\tif ((ctx->opts->flags & COMMIT_GRAPH_WRITE_SPLIT) &&\n+\t    ctx->base_graph_name && ctx->num_commit_graphs_after > 1) {\n \t\tchar *new_base_hash = xstrdup(oid_to_hex(&ctx->new_base_graph->oid));\n \t\tchar *new_base_name = get_split_graph_filename(ctx->new_base_graph->dir, new_base_hash);\n \n@@ -2227,7 +2227,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t\t\t  CSUM_HASH_IN_STREAM | CSUM_FSYNC);\n \tfree_chunkfile(cf);\n \n-\tif (ctx->split) {\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_SPLIT) {\n \t\tFILE *chainf = fdopen_lock_file(&lk, \"w\");\n \t\tchar *final_graph_name;\n \t\tint result;\n@@ -2406,7 +2406,7 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)\n {\n \tuint32_t i, dedup_i = 0;\n \n-\tif (ctx->report_progress)\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tctx->progress = start_delayed_progress(\n \t\t\t\t\tctx->r,\n \t\t\t\t\t_(\"Scanning merged commits\"),\n@@ -2452,7 +2452,7 @@ static void merge_commit_graphs(struct write_commit_graph_context *ctx,\n \twhile (g && current_graph_number >= ctx->num_commit_graphs_after) {\n \t\tcurrent_graph_number--;\n \n-\t\tif (ctx->report_progress)\n+\t\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\t\tctx->progress = start_delayed_progress(ctx->r,\n \t\t\t\t\t\t\t       _(\"Merging commit-graph\"), 0);\n \n@@ -2501,7 +2501,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \n \tif (ctx->opts->expire_time)\n \t\texpire_time = ctx->opts->expire_time;\n-\tif (!ctx->split) {\n+\tif (!(ctx->opts->flags & COMMIT_GRAPH_WRITE_SPLIT)) {\n \t\tchar *chain_file_name = get_commit_graph_chain_filename(ctx->dir);\n \t\tunlink(chain_file_name);\n \t\tfree(chain_file_name);\n@@ -2558,9 +2558,6 @@ int write_commit_graph(struct repository *r,\n {\n \tstruct write_commit_graph_context ctx = {\n \t\t.r = r,\n-\t\t.append = opts->flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0,\n-\t\t.report_progress = opts->flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0,\n-\t\t.split = opts->flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,\n \t\t.opts = opts,\n \t\t.total_bloom_filter_data_size = 0,\n \t\t.write_generation_data = (get_configured_generation_version(r) == 2),\n@@ -2624,7 +2621,7 @@ int write_commit_graph(struct repository *r,\n \n \tbloom_settings.hash_version = bloom_settings.hash_version == 2 ? 2 : 1;\n \n-\tif (ctx.split) {\n+\tif (ctx.opts->flags & COMMIT_GRAPH_WRITE_SPLIT) {\n \t\tfor (struct commit_graph *chain = g; chain; chain = chain->base_graph)\n \t\t\tctx.num_commit_graphs_before++;\n \n@@ -2642,7 +2639,7 @@ int write_commit_graph(struct repository *r,\n \tif (odb_count_objects(r->objects, ODB_COUNT_OBJECTS_APPROXIMATE, &ctx.approx_nr_objects) < 0)\n \t\tctx.approx_nr_objects = 0;\n \n-\tif (ctx.append && g) {\n+\tif ((ctx.opts->flags & COMMIT_GRAPH_WRITE_APPEND) && g) {\n \t\tfor (i = 0; i < g->num_commits; i++) {\n \t\t\tstruct object_id oid;\n \t\t\toidread(&oid, g->chunk_oid_lookup + st_mult(g->hash_algo->rawsz, i),\n@@ -2680,7 +2677,7 @@ int write_commit_graph(struct repository *r,\n \tif (!ctx.commits.nr && !replace)\n \t\tgoto cleanup;\n \n-\tif (ctx.split) {\n+\tif (ctx.opts->flags & COMMIT_GRAPH_WRITE_SPLIT) {\n \t\tsplit_graph_merge_strategy(&ctx, g);\n \n \t\tif (!replace)\n@@ -2703,7 +2700,7 @@ int write_commit_graph(struct repository *r,\n \tif (ctx.changed_paths)\n \t\tdeinit_bloom_filters();\n \n-\tif (ctx.split)\n+\tif (ctx.opts->flags & COMMIT_GRAPH_WRITE_SPLIT)\n \t\tmark_commit_graphs(&ctx);\n \n \texpire_commit_graphs(&ctx);\n\n-- \n2.56.0.500.g5d06dc02cd.dirty\n\n\n"},{"id":"557453","messageId":"20261104-pks-commit-graph-write-refactorings-v1-5-d013d9401a59@pks.im","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"[PATCH 05/10] commit-graph: merge the two commit graph writers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:27Z","receivedAt":"2026-11-04T15:57:27Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We have two entry points for writing commit graphs:\n\n  - `write_commit_graph()` either writes a commit graph for all commits\n    in the object database, or for the commits specified via its options\n    struct.\n\n  - `write_commit_graph_reachable()` writes a commit graph for all\n    reachable commits.\n\nIt's somewhat pointless though to have a separate entry point for\nwriting a commit graph for reachable commits, as this use case can be\ntrivially satisfied via a flag.\n\nIntroduce that flag and drop the separate entry point in favor of\n`write_commit_graph()`. This ensures we have a single entry point for\nwriting commit graphs, only, which will make it easier to eventually\nintroduce pluggable commit graphs via the object database.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c |  8 ++------\n builtin/fetch.c        |  7 +++++--\n builtin/gc.c           |  5 +++--\n commit-graph.c         | 47 ++++++++++++++++++++++-------------------------\n commit-graph.h         |  4 +---\n 5 files changed, 33 insertions(+), 38 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex d49faf543b4..644f7736c91 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -299,17 +299,13 @@ static int cmd_commit_graph_write(int argc,\n \tif (opts.enable_changed_paths == 1 ||\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n+\tif (opts.reachable)\n+\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;\n \n \tdir = odb_source_files_find_dir(repo->objects, opts.obj_dir);\n \tif (!dir)\n \t\tdie(_(\"could not find object directory matching %s\"), opts.obj_dir);\n \n-\tif (opts.reachable) {\n-\t\tif (write_commit_graph_reachable(repo, dir->abspath, &write_opts))\n-\t\t\tresult = 1;\n-\t\tgoto cleanup;\n-\t}\n-\n \tif (opts.stdin_packs) {\n \t\tstruct strbuf packname = STRBUF_INIT;\n \t\tsize_t dirlen;\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex b76e7725728..637d7ddaa06 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2941,6 +2941,8 @@ int cmd_fetch(int argc,\n \t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_SPLIT;\n \t\tif (progress)\n \t\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n+\t\tif (graph_write_mode != GRAPH_WRITE_TIPS)\n+\t\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;\n \n \t\tif (graph_write_mode != GRAPH_WRITE_SKIP) {\n \t\t\ttrace2_region_enter(\"fetch\", \"write-commit-graph\",\n@@ -2951,9 +2953,10 @@ int cmd_fetch(int argc,\n \t\t\t\t\tthe_repository->objects->source->path,\n \t\t\t\t\tNULL, &updated_tips, &write_opts);\n \t\t\telse\n-\t\t\t\twrite_commit_graph_reachable(\n+\t\t\t\twrite_commit_graph(\n \t\t\t\t\tthe_repository,\n-\t\t\t\t\tthe_repository->objects->source->path, &write_opts);\n+\t\t\t\t\tthe_repository->objects->source->path,\n+\t\t\t\t\tNULL, NULL, &write_opts);\n \t\t\ttrace2_region_leave(\"fetch\", \"write-commit-graph\",\n \t\t\t\t\t    the_repository);\n \t\t}\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex a157909ed54..709789dbf2c 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -737,11 +737,12 @@ int cmd_gc(int argc,\n \tif (the_repository->settings.gc_write_commit_graph == 1) {\n \t\tstruct commit_graph_write_options write_opts = COMMIT_GRAPH_WRITE_OPTIONS_INIT;\n \n+\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;\n \t\tif (!opts.quiet && !daemonized)\n \t\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\t\twrite_commit_graph_reachable(the_repository,\n-\t\t\t\t\t     the_repository->objects->source->path, &write_opts);\n+\t\twrite_commit_graph(the_repository, the_repository->objects->source->path,\n+\t\t\t\t   NULL, NULL, &write_opts);\n \t}\n \n \tif (!daemonized) {\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 4f3563f4d0b..97be0f71484 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -37,10 +37,11 @@ void git_test_write_commit_graph_or_die(struct repository *repo)\n \tif (!git_env_bool(GIT_TEST_COMMIT_GRAPH, 0))\n \t\treturn;\n \n+\topts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;\n \tif (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\topts.flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tif (write_commit_graph_reachable(repo, repo->objects->source->path, &opts))\n+\tif (write_commit_graph(repo, repo->objects->source->path, NULL, NULL, &opts))\n \t\tdie(\"failed to write commit-graph under GIT_TEST_COMMIT_GRAPH\");\n }\n \n@@ -1910,32 +1911,23 @@ static int add_ref_to_set(const struct reference *ref, void *cb_data)\n \treturn 0;\n }\n \n-int write_commit_graph_reachable(struct repository *repo,\n-\t\t\t\t const char *dir,\n-\t\t\t\t const struct commit_graph_write_options *opts)\n+static void fill_oids_from_reachable(struct write_commit_graph_context *ctx,\n+\t\t\t\t     struct oidset *commits)\n {\n-\tstruct oidset commits = OIDSET_INIT;\n-\tstruct refs_cb_data data;\n-\tint result;\n-\n-\tmemset(&data, 0, sizeof(data));\n-\tdata.repo = repo;\n-\tdata.commits = &commits;\n+\tstruct refs_cb_data data = {\n+\t\t.repo = ctx->r,\n+\t\t.commits = commits,\n+\t};\n \n-\tif (opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n+\tif (ctx->opts->flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\tdata.progress = start_delayed_progress(\n-\t\t\trepo,\n+\t\t\tctx->r,\n \t\t\t_(\"Collecting referenced commits\"), 0);\n \n-\trefs_for_each_ref(get_main_ref_store(repo), add_ref_to_set,\n+\trefs_for_each_ref(get_main_ref_store(ctx->r), add_ref_to_set,\n \t\t\t  &data);\n \n \tstop_progress(&data.progress);\n-\n-\tresult = write_commit_graph(repo, dir, NULL, &commits, opts);\n-\n-\toidset_clear(&commits);\n-\treturn result;\n }\n \n static int fill_oids_from_packs(struct write_commit_graph_context *ctx,\n@@ -2567,9 +2559,13 @@ int write_commit_graph(struct repository *r,\n \tint res = 0;\n \tint replace = 0;\n \tstruct bloom_filter_settings bloom_settings = DEFAULT_BLOOM_FILTER_SETTINGS;\n+\tstruct oidset reachable_commits = OIDSET_INIT;\n \tstruct topo_level_slab topo_levels;\n \tstruct commit_graph *g;\n \n+\tif (!!pack_indexes + !!commits + !!(opts->flags & COMMIT_GRAPH_WRITE_REACHABLE) > 1)\n+\t\tBUG(\"attempting to write commit-graph with mutually incompatible options\");\n+\n \tprepare_repo_settings(r);\n \tif (!r->settings.core_commit_graph) {\n \t\twarning(_(\"attempting to write a commit-graph, but 'core.commitGraph' is disabled\"));\n@@ -2652,14 +2648,14 @@ int write_commit_graph(struct repository *r,\n \t\tctx.order_by_pack = 1;\n \t\tif ((res = fill_oids_from_packs(&ctx, pack_indexes)))\n \t\t\tgoto cleanup;\n-\t}\n-\n-\tif (commits) {\n+\t} else if (commits) {\n \t\tif ((res = fill_oids_from_commits(&ctx, commits)))\n \t\t\tgoto cleanup;\n-\t}\n-\n-\tif (!pack_indexes && !commits) {\n+\t} else if (opts->flags & COMMIT_GRAPH_WRITE_REACHABLE) {\n+\t\tfill_oids_from_reachable(&ctx, &reachable_commits);\n+\t\tif ((res = fill_oids_from_commits(&ctx, &reachable_commits)))\n+\t\t\tgoto cleanup;\n+\t} else {\n \t\tctx.order_by_pack = 1;\n \t\tfill_oids_from_all_packs(&ctx);\n \t}\n@@ -2710,6 +2706,7 @@ int write_commit_graph(struct repository *r,\n \tfree(ctx.base_graph_name);\n \tfree(ctx.dir);\n \tcommit_stack_clear(&ctx.commits);\n+\toidset_clear(&reachable_commits);\n \toid_array_clear(&ctx.oids);\n \tclear_topo_level_slab(&topo_levels);\n \ndiff --git a/commit-graph.h b/commit-graph.h\nindex 7461093a990..4adbd5f18d9 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -160,6 +160,7 @@ enum commit_graph_write_flags {\n \tCOMMIT_GRAPH_WRITE_SPLIT      = (1 << 2),\n \tCOMMIT_GRAPH_WRITE_BLOOM_FILTERS = (1 << 3),\n \tCOMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS = (1 << 4),\n+\tCOMMIT_GRAPH_WRITE_REACHABLE  = (1 << 5),\n };\n \n enum commit_graph_split_flags {\n@@ -192,9 +193,6 @@ struct commit_graph_write_options {\n  * canonicalized internally so that it compares equal to the directory of\n  * graphs that have already been loaded.\n  */\n-int write_commit_graph_reachable(struct repository *repo,\n-\t\t\t\t const char *dir,\n-\t\t\t\t const struct commit_graph_write_options *opts);\n int write_commit_graph(struct repository *r,\n \t\t       const char *dir,\n \t\t       const struct string_list *pack_indexes,\n\n-- \n2.56.0.500.g5d06dc02cd.dirty\n\n\n"},{"id":"557454","messageId":"20261104-pks-commit-graph-write-refactorings-v1-6-d013d9401a59@pks.im","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"[PATCH 06/10] commit-graph: move remaining write parameters into options","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:28Z","receivedAt":"2026-11-04T15:57:28Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Move the remaining optional parameters that can be passed to\n`write_commit_graph()` into its options structure to simplify the\nfunction's calling convention.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c |  7 +++----\n builtin/fetch.c        | 15 +++++----------\n builtin/gc.c           |  2 +-\n commit-graph.c         | 14 ++++++--------\n commit-graph.h         |  4 ++--\n 5 files changed, 17 insertions(+), 25 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 644f7736c91..f2c374d0176 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -319,6 +319,7 @@ static int cmd_commit_graph_write(int argc,\n \t\t\tstring_list_append(&pack_indexes, packname.buf);\n \t\t}\n \n+\t\twrite_opts.pack_indexes = &pack_indexes;\n \t\tstrbuf_release(&packname);\n \t} else if (opts.stdin_commits) {\n \t\toidset_init(&commits, 0);\n@@ -335,13 +336,11 @@ static int cmd_commit_graph_write(int argc,\n \t\t\t}\n \t\t}\n \n+\t\twrite_opts.commits = &commits;\n \t\tstop_progress(&progress);\n \t}\n \n-\tif (write_commit_graph(repo, dir->abspath,\n-\t\t\t       opts.stdin_packs ? &pack_indexes : NULL,\n-\t\t\t       opts.stdin_commits ? &commits : NULL,\n-\t\t\t       &write_opts))\n+\tif (write_commit_graph(repo, dir->abspath, &write_opts))\n \t\tresult = 1;\n \n cleanup:\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 637d7ddaa06..7278cee8ca7 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2943,20 +2943,15 @@ int cmd_fetch(int argc,\n \t\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \t\tif (graph_write_mode != GRAPH_WRITE_TIPS)\n \t\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;\n+\t\telse\n+\t\t\twrite_opts.commits = &updated_tips;\n \n \t\tif (graph_write_mode != GRAPH_WRITE_SKIP) {\n \t\t\ttrace2_region_enter(\"fetch\", \"write-commit-graph\",\n \t\t\t\t\t    the_repository);\n-\t\t\tif (graph_write_mode == GRAPH_WRITE_TIPS)\n-\t\t\t\twrite_commit_graph(\n-\t\t\t\t\tthe_repository,\n-\t\t\t\t\tthe_repository->objects->source->path,\n-\t\t\t\t\tNULL, &updated_tips, &write_opts);\n-\t\t\telse\n-\t\t\t\twrite_commit_graph(\n-\t\t\t\t\tthe_repository,\n-\t\t\t\t\tthe_repository->objects->source->path,\n-\t\t\t\t\tNULL, NULL, &write_opts);\n+\t\t\twrite_commit_graph(the_repository,\n+\t\t\t\t\t   the_repository->objects->source->path,\n+\t\t\t\t\t   &write_opts);\n \t\t\ttrace2_region_leave(\"fetch\", \"write-commit-graph\",\n \t\t\t\t\t    the_repository);\n \t\t}\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 709789dbf2c..7bf88861df0 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -742,7 +742,7 @@ int cmd_gc(int argc,\n \t\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n \t\twrite_commit_graph(the_repository, the_repository->objects->source->path,\n-\t\t\t\t   NULL, NULL, &write_opts);\n+\t\t\t\t   &write_opts);\n \t}\n \n \tif (!daemonized) {\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 97be0f71484..077213b5336 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -41,7 +41,7 @@ void git_test_write_commit_graph_or_die(struct repository *repo)\n \tif (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\topts.flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tif (write_commit_graph(repo, repo->objects->source->path, NULL, NULL, &opts))\n+\tif (write_commit_graph(repo, repo->objects->source->path, &opts))\n \t\tdie(\"failed to write commit-graph under GIT_TEST_COMMIT_GRAPH\");\n }\n \n@@ -2544,8 +2544,6 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \n int write_commit_graph(struct repository *r,\n \t\t       const char *dir,\n-\t\t       const struct string_list *const pack_indexes,\n-\t\t       struct oidset *commits,\n \t\t       const struct commit_graph_write_options *opts)\n {\n \tstruct write_commit_graph_context ctx = {\n@@ -2563,7 +2561,7 @@ int write_commit_graph(struct repository *r,\n \tstruct topo_level_slab topo_levels;\n \tstruct commit_graph *g;\n \n-\tif (!!pack_indexes + !!commits + !!(opts->flags & COMMIT_GRAPH_WRITE_REACHABLE) > 1)\n+\tif (!!opts->pack_indexes + !!opts->commits + !!(opts->flags & COMMIT_GRAPH_WRITE_REACHABLE) > 1)\n \t\tBUG(\"attempting to write commit-graph with mutually incompatible options\");\n \n \tprepare_repo_settings(r);\n@@ -2644,12 +2642,12 @@ int write_commit_graph(struct repository *r,\n \t\t}\n \t}\n \n-\tif (pack_indexes) {\n+\tif (opts->pack_indexes) {\n \t\tctx.order_by_pack = 1;\n-\t\tif ((res = fill_oids_from_packs(&ctx, pack_indexes)))\n+\t\tif ((res = fill_oids_from_packs(&ctx, opts->pack_indexes)))\n \t\t\tgoto cleanup;\n-\t} else if (commits) {\n-\t\tif ((res = fill_oids_from_commits(&ctx, commits)))\n+\t} else if (opts->commits) {\n+\t\tif ((res = fill_oids_from_commits(&ctx, opts->commits)))\n \t\t\tgoto cleanup;\n \t} else if (opts->flags & COMMIT_GRAPH_WRITE_REACHABLE) {\n \t\tfill_oids_from_reachable(&ctx, &reachable_commits);\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 4adbd5f18d9..0e03e82a04a 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -171,6 +171,8 @@ enum commit_graph_split_flags {\n \n struct commit_graph_write_options {\n \tenum commit_graph_write_flags flags;\n+\tconst struct string_list *pack_indexes;\n+\tstruct oidset *commits;\n \tint size_multiple;\n \tint max_commits;\n \ttimestamp_t expire_time;\n@@ -195,8 +197,6 @@ struct commit_graph_write_options {\n  */\n int write_commit_graph(struct repository *r,\n \t\t       const char *dir,\n-\t\t       const struct string_list *pack_indexes,\n-\t\t       struct oidset *commits,\n \t\t       const struct commit_graph_write_options *opts);\n \n #define COMMIT_GRAPH_VERIFY_SHALLOW\t(1 << 0)\n\n-- \n2.56.0.500.g5d06dc02cd.dirty\n\n\n"},{"id":"557455","messageId":"20261104-pks-commit-graph-write-refactorings-v1-7-d013d9401a59@pks.im","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"[PATCH 07/10] commit-graph: fix mixup of write/verify flags","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:29Z","receivedAt":"2026-11-04T15:57:29Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"While we already have flags specific to `verify_commit_graph()`, the\nfunction also uses `COMMIT_GRAPH_WRITE_PROGRESS`. This mixup is a bit of\na footgun though, as it may easily happen that the value of that flag\nis the exact same value as a future `COMMIT_GRAPH_VERIFY_*` flag.\n\nFix this mixup by introducing a new `COMMIT_GRAPH_VERIFY_PROGRESS` flag.\nWhile at it, convert the verify flags into an enum.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c | 4 ++--\n commit-graph.c         | 5 +++--\n commit-graph.h         | 8 ++++++--\n 3 files changed, 11 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex f2c374d0176..09b09d6ac5c 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -70,9 +70,9 @@ static int cmd_commit_graph_verify(int argc,\n \tchar *graph_name;\n \tchar *chain_name;\n \tenum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;\n+\tenum commit_graph_verify_flags flags = 0;\n \tint fd;\n \tstruct stat st;\n-\tint flags = 0;\n \tint incomplete_chain = 0;\n \tint ret;\n \tstruct option options[] = {\n@@ -97,7 +97,7 @@ static int cmd_commit_graph_verify(int argc,\n \tif (opts.shallow)\n \t\tflags |= COMMIT_GRAPH_VERIFY_SHALLOW;\n \tif (opts.progress)\n-\t\tflags |= COMMIT_GRAPH_WRITE_PROGRESS;\n+\t\tflags |= COMMIT_GRAPH_VERIFY_PROGRESS;\n \n \tdir = odb_source_files_find_dir(repo->objects, opts.obj_dir);\n \tif (!dir)\ndiff --git a/commit-graph.c b/commit-graph.c\nindex 077213b5336..c82776b0667 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -2904,7 +2904,8 @@ static int verify_one_commit_graph(struct commit_graph *g,\n \treturn verify_commit_graph_error;\n }\n \n-int verify_commit_graph(struct commit_graph *g, int flags)\n+int verify_commit_graph(struct commit_graph *g,\n+\t\t\tenum commit_graph_verify_flags flags)\n {\n \tstruct progress *progress = NULL;\n \tint local_error = 0;\n@@ -2915,7 +2916,7 @@ int verify_commit_graph(struct commit_graph *g, int flags)\n \t\treturn 1;\n \t}\n \n-\tif (flags & COMMIT_GRAPH_WRITE_PROGRESS) {\n+\tif (flags & COMMIT_GRAPH_VERIFY_PROGRESS) {\n \t\tuint64_t total = g->num_commits;\n \t\tif (!(flags & COMMIT_GRAPH_VERIFY_SHALLOW))\n \t\t\ttotal += g->num_commits_in_base;\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 0e03e82a04a..80d59bd23bd 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -199,9 +199,13 @@ int write_commit_graph(struct repository *r,\n \t\t       const char *dir,\n \t\t       const struct commit_graph_write_options *opts);\n \n-#define COMMIT_GRAPH_VERIFY_SHALLOW\t(1 << 0)\n+enum commit_graph_verify_flags {\n+\tCOMMIT_GRAPH_VERIFY_SHALLOW = (1 << 0),\n+\tCOMMIT_GRAPH_VERIFY_PROGRESS = (1 << 1),\n+};\n \n-int verify_commit_graph(struct commit_graph *g, int flags);\n+int verify_commit_graph(struct commit_graph *g,\n+\t\t\tenum commit_graph_verify_flags flags);\n \n void close_commit_graph(struct object_database *);\n void free_commit_graph(struct commit_graph *);\n\n-- \n2.56.0.500.g5d06dc02cd.dirty\n\n\n"},{"id":"557456","messageId":"20261104-pks-commit-graph-write-refactorings-v1-8-d013d9401a59@pks.im","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"[PATCH 08/10] builtin/commit-graph: set flags directly","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:30Z","receivedAt":"2026-11-04T15:57:30Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"We have a bit of an unnecessary indirection when parsing flags for both\nthe \"write\" and \"verify\" subcommands: instead of setting the flags\ndirectly via a local flags variable, we instead populate them into a\n`struct opts_commit_graph` only to then set the flag. This is awkward\nand unnecessarily verbose.\n\nDrop the separate flags in `struct opts_commit_graph` and set them\ndirectly via `OPT_BIT()` instead.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/commit-graph.c | 54 ++++++++++++++++++--------------------------------\n 1 file changed, 19 insertions(+), 35 deletions(-)\n\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 09b09d6ac5c..218c30ed3ed 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -42,13 +42,8 @@ static char const * const builtin_commit_graph_usage[] = {\n \n struct opts_commit_graph {\n \tconst char *obj_dir;\n-\tint reachable;\n \tint stdin_packs;\n \tint stdin_commits;\n-\tint append;\n-\tint split;\n-\tint shallow;\n-\tint progress;\n \tint enable_changed_paths;\n };\n \n@@ -62,24 +57,23 @@ static int cmd_commit_graph_verify(int argc,\n \t\t\t\t   const char *prefix,\n \t\t\t\t   struct repository *repo)\n {\n-\tstruct opts_commit_graph opts = {\n-\t\t.progress = isatty(2),\n-\t};\n+\tstruct opts_commit_graph opts = { 0 };\n \tstruct commit_graph *graph = NULL;\n \tstruct odb_files_dir *dir = NULL;\n \tchar *graph_name;\n \tchar *chain_name;\n \tenum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE;\n-\tenum commit_graph_verify_flags flags = 0;\n+\tenum commit_graph_verify_flags flags = isatty(2) ? COMMIT_GRAPH_VERIFY_PROGRESS : 0;\n \tint fd;\n \tstruct stat st;\n \tint incomplete_chain = 0;\n \tint ret;\n \tstruct option options[] = {\n-\t\tOPT_BOOL(0, \"shallow\", &opts.shallow,\n-\t\t\t N_(\"if the commit-graph is split, only verify the tip file\")),\n-\t\tOPT_BOOL(0, \"progress\", &opts.progress,\n-\t\t\t N_(\"force progress reporting\")),\n+\t\tOPT_BIT(0, \"shallow\", &flags,\n+\t\t\tN_(\"if the commit-graph is split, only verify the tip file\"),\n+\t\t\tCOMMIT_GRAPH_VERIFY_SHALLOW),\n+\t\tOPT_BIT(0, \"progress\", &flags,\n+\t\t\tN_(\"force progress reporting\"), COMMIT_GRAPH_VERIFY_PROGRESS),\n \t\tCOMMIT_GRAPH_COMMON_OPTIONS(&opts),\n \t\tOPT_END(),\n \t};\n@@ -94,10 +88,6 @@ static int cmd_commit_graph_verify(int argc,\n \n \tif (!opts.obj_dir)\n \t\topts.obj_dir = repo_get_object_directory(repo);\n-\tif (opts.shallow)\n-\t\tflags |= COMMIT_GRAPH_VERIFY_SHALLOW;\n-\tif (opts.progress)\n-\t\tflags |= COMMIT_GRAPH_VERIFY_PROGRESS;\n \n \tdir = odb_source_files_find_dir(repo->objects, opts.obj_dir);\n \tif (!dir)\n@@ -152,7 +142,7 @@ static int write_option_parse_split(const struct option *opt, const char *arg,\n \n \tBUG_ON_OPT_NEG(unset);\n \n-\tdata->opts->split = 1;\n+\tdata->write_opts->flags |= COMMIT_GRAPH_WRITE_SPLIT;\n \tif (!arg)\n \t\treturn 0;\n \n@@ -231,7 +221,6 @@ static int cmd_commit_graph_write(int argc,\n {\n \tstruct commit_graph_write_options write_opts = COMMIT_GRAPH_WRITE_OPTIONS_INIT;\n \tstruct opts_commit_graph opts = {\n-\t\t.progress = isatty(2),\n \t\t.enable_changed_paths = -1,\n \t};\n \tstruct commit_graph_write_config_data config_data = {\n@@ -245,14 +234,15 @@ static int cmd_commit_graph_write(int argc,\n \tint result = 0;\n \tstruct progress *progress = NULL;\n \tstruct option options[] = {\n-\t\tOPT_BOOL(0, \"reachable\", &opts.reachable,\n-\t\t\tN_(\"start walk at all refs\")),\n+\t\tOPT_BIT(0, \"reachable\", &write_opts.flags,\n+\t\t\tN_(\"start walk at all refs\"), COMMIT_GRAPH_WRITE_REACHABLE),\n \t\tOPT_BOOL(0, \"stdin-packs\", &opts.stdin_packs,\n \t\t\tN_(\"scan pack-indexes listed by stdin for commits\")),\n \t\tOPT_BOOL(0, \"stdin-commits\", &opts.stdin_commits,\n \t\t\tN_(\"start walk at commits listed by stdin\")),\n-\t\tOPT_BOOL(0, \"append\", &opts.append,\n-\t\t\tN_(\"include all commits already in the commit-graph file\")),\n+\t\tOPT_BIT(0, \"append\", &write_opts.flags,\n+\t\t\tN_(\"include all commits already in the commit-graph file\"),\n+\t\t\tCOMMIT_GRAPH_WRITE_APPEND),\n \t\tOPT_BOOL(0, \"changed-paths\", &opts.enable_changed_paths,\n \t\t\tN_(\"enable computation for changed paths\")),\n \t\tOPT_CALLBACK_F(0, \"split\", &config_data, NULL,\n@@ -268,14 +258,16 @@ static int cmd_commit_graph_write(int argc,\n \t\tOPT_CALLBACK_F(0, \"max-new-filters\", &write_opts.max_new_filters,\n \t\t\tNULL, N_(\"maximum number of changed-path Bloom filters to compute\"),\n \t\t\t0, write_option_max_new_filters),\n-\t\tOPT_BOOL(0, \"progress\", &opts.progress,\n-\t\t\t N_(\"force progress reporting\")),\n+\t\tOPT_BIT(0, \"progress\", &write_opts.flags,\n+\t\t\tN_(\"force progress reporting\"), COMMIT_GRAPH_WRITE_PROGRESS),\n \t\tCOMMIT_GRAPH_COMMON_OPTIONS(&opts),\n \t\tOPT_END(),\n \t};\n \n \ttrace2_cmd_mode(\"write\");\n \n+\twrite_opts.flags |= isatty(2) ? COMMIT_GRAPH_WRITE_PROGRESS : 0;\n+\n \trepo_config(repo, git_commit_graph_write_config, &config_data);\n \n \targc = parse_options(argc, argv, prefix,\n@@ -284,23 +276,15 @@ static int cmd_commit_graph_write(int argc,\n \tif (argc)\n \t\tusage_with_options(builtin_commit_graph_write_usage, options);\n \n-\tif (opts.reachable + opts.stdin_packs + opts.stdin_commits > 1)\n+\tif (!!(write_opts.flags & COMMIT_GRAPH_WRITE_REACHABLE) + opts.stdin_packs + opts.stdin_commits > 1)\n \t\tdie(_(\"use at most one of --reachable, --stdin-commits, or --stdin-packs\"));\n \tif (!opts.obj_dir)\n \t\topts.obj_dir = repo_get_object_directory(repo);\n-\tif (opts.append)\n-\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_APPEND;\n-\tif (opts.split)\n-\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_SPLIT;\n-\tif (opts.progress)\n-\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \tif (!opts.enable_changed_paths)\n \t\twrite_opts.flags |= COMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS;\n \tif (opts.enable_changed_paths == 1 ||\n \t    git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n-\tif (opts.reachable)\n-\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;\n \n \tdir = odb_source_files_find_dir(repo->objects, opts.obj_dir);\n \tif (!dir)\n@@ -323,7 +307,7 @@ static int cmd_commit_graph_write(int argc,\n \t\tstrbuf_release(&packname);\n \t} else if (opts.stdin_commits) {\n \t\toidset_init(&commits, 0);\n-\t\tif (opts.progress)\n+\t\tif (write_opts.flags & COMMIT_GRAPH_WRITE_PROGRESS)\n \t\t\tprogress = start_delayed_progress(\n \t\t\t\trepo,\n \t\t\t\t_(\"Collecting commits from input\"), 0);\n\n-- \n2.56.0.500.g5d06dc02cd.dirty\n\n\n"},{"id":"557457","messageId":"20261104-pks-commit-graph-write-refactorings-v1-9-d013d9401a59@pks.im","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"[PATCH 09/10] odb/source-files: verify commit-graphs as part of fsck","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:31Z","receivedAt":"2026-11-04T15:57:31Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"git-fsck(1) verifies commit-graphs by downcasting the object database's\nsource to the \"files\" backend and spawning `git commit-graph verify\n--object-dir` for each of its object directories. But starting with\n14bf3a43f8b (Merge branch 'ps/odb-pluggable-fsck', 2026-09-15) we have\nadapted git-fsck(1) so that the verification of the object database is\npluggable.\n\nIn a subsequent patch series we're also about to make commit graphs\nthemselves pluggable so that a backend can choose where exactly a commit\ngraph is stored. As part of that, we'll also have to make verification\nof commit graphs pluggable in the same way.\n\nMove the verification into `odb_source_files_fsck()`, same as we did for\nmulti-pack indices, bitmaps and all the other auxiliary data structures.\nSame as when we adapted consistency checks for those, there are a couple\nof consequences here:\n\n  - Commit graphs stored in alternates are only verified when\n    `ODB_FSCK_FULL` is set, which is the default for git-fsck(1).\n\n  - Commit-graphs are not verified with `--connectivity-only` anymore,\n    as that mode skips the object database checks altogether.\n\n  - Failures are reported via `ERROR_OBJECT` instead of a dedicated\n    exit code bit, same as we have dropped `ERROR_MIDX` et al. Those\n    error codes were never documented or exercised anywhere.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/fsck.c     | 20 --------------------\n odb/source-files.c | 25 +++++++++++++++++++++++++\n 2 files changed, 25 insertions(+), 20 deletions(-)\n\ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 710780e35a8..c4558efcf18 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -46,7 +46,6 @@ static timestamp_t now;\n #define ERROR_OBJECT 01\n #define ERROR_REACHABLE 02\n #define ERROR_REFS 010\n-#define ERROR_COMMIT_GRAPH 020\n \n static const char *describe_object(const struct object_id *oid)\n {\n@@ -913,7 +912,6 @@ int cmd_fsck(int argc,\n \t\tfsck_enable_object_names(&fsck_walk_options);\n \n \trepo_config(repo, git_fsck_config, &fsck_obj_options);\n-\tprepare_repo_settings(repo);\n \n \tif (check_references)\n \t\tfsck_refs(repo);\n@@ -984,24 +982,6 @@ int cmd_fsck(int argc,\n \n \tcheck_connectivity(repo);\n \n-\tif (repo->settings.core_commit_graph) {\n-\t\tstruct odb_source_files *files = odb_source_files_downcast(repo->objects->source);\n-\t\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n-\n-\t\tfor (struct odb_files_dir *dir = files->dirs; dir; dir = dir->next) {\n-\t\t\tchild_process_init(&commit_graph_verify);\n-\t\t\tcommit_graph_verify.git_cmd = 1;\n-\t\t\tstrvec_pushl(&commit_graph_verify.args, \"commit-graph\",\n-\t\t\t\t     \"verify\", \"--object-dir\", dir->abspath, NULL);\n-\t\t\tif (show_progress)\n-\t\t\t\tstrvec_push(&commit_graph_verify.args, \"--progress\");\n-\t\t\telse\n-\t\t\t\tstrvec_push(&commit_graph_verify.args, \"--no-progress\");\n-\t\t\tif (run_command(&commit_graph_verify))\n-\t\t\t\terrors_found |= ERROR_COMMIT_GRAPH;\n-\t\t}\n-\t}\n-\n \tfree_snapshot_refs(&snap);\n \treturn errors_found;\n }\ndiff --git a/odb/source-files.c b/odb/source-files.c\nindex 5b4277fbfd3..224b47e38b1 100644\n--- a/odb/source-files.c\n+++ b/odb/source-files.c\n@@ -1215,6 +1215,30 @@ static int odb_source_files_generate_pack(struct odb_source *source UNUSED,\n \treturn 0;\n }\n \n+static int fsck_commit_graph(struct odb_source_files *files,\n+\t\t\t     struct odb_files_dir *dir,\n+\t\t\t     struct odb_fsck_options *opts)\n+{\n+\tstruct repository *repo = files->base.odb->repo;\n+\tstruct child_process commit_graph_verify = CHILD_PROCESS_INIT;\n+\n+\tprepare_repo_settings(repo);\n+\tif (!repo->settings.core_commit_graph)\n+\t\treturn 0;\n+\n+\tcommit_graph_verify.git_cmd = 1;\n+\tstrvec_pushl(&commit_graph_verify.args, \"commit-graph\", \"verify\",\n+\t\t     \"--object-dir\", dir->abspath, NULL);\n+\tif (opts->flags & ODB_FSCK_PROGRESS)\n+\t\tstrvec_push(&commit_graph_verify.args, \"--progress\");\n+\telse\n+\t\tstrvec_push(&commit_graph_verify.args, \"--no-progress\");\n+\tif (run_command(&commit_graph_verify))\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n static int odb_source_files_fsck(struct odb_source *source,\n \t\t\t\t struct odb_fsck_options *opts)\n {\n@@ -1227,6 +1251,7 @@ static int odb_source_files_fsck(struct odb_source *source,\n \n \t\tret |= odb_source_fsck(&dir->loose->base, opts);\n \t\tret |= odb_source_fsck(&dir->packed->base, opts);\n+\t\tret |= fsck_commit_graph(files, dir, opts);\n \t}\n \n \treturn ret;\n\n-- \n2.56.0.500.g5d06dc02cd.dirty\n\n\n"},{"id":"557458","messageId":"20261104-pks-commit-graph-write-refactorings-v1-10-d013d9401a59@pks.im","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"[PATCH 10/10] commit-graph: modernize function names","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-04T15:57:32Z","receivedAt":"2026-11-04T15:57:32Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Modernize a couple of function names of the commit-graph subsystem so\nthat they follow our modern `<subsystem>_<verb>` naming schema.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/gitformat-chunk.adoc |  2 +-\n builtin/commit-graph.c             |  6 +++---\n builtin/fetch.c                    |  2 +-\n builtin/gc.c                       |  2 +-\n commit-graph.c                     | 20 ++++++++++----------\n commit-graph.h                     | 14 +++++++-------\n odb.c                              |  2 +-\n oss-fuzz/fuzz-commit-graph.c       |  4 ++--\n t/helper/test-read-graph.c         |  2 +-\n 9 files changed, 27 insertions(+), 27 deletions(-)\n\ndiff --git a/Documentation/gitformat-chunk.adoc b/Documentation/gitformat-chunk.adoc\nindex 3315df6201d..061803932b4 100644\n--- a/Documentation/gitformat-chunk.adoc\n+++ b/Documentation/gitformat-chunk.adoc\n@@ -118,7 +118,7 @@ Examples\n These file formats use the chunk-format API, and can be used as examples\n for future formats:\n \n-* *commit-graph:* see `write_commit_graph_file()` and `parse_commit_graph()`\n+* *commit-graph:* see `write_commit_graph_file()` and `commit_graph_parse()`\n   in `commit-graph.c` for how the chunk-format API is used to write and\n   parse the commit-graph file format documented in\n   the commit-graph file format in linkgit:gitformat-commit-graph[5].\ndiff --git a/builtin/commit-graph.c b/builtin/commit-graph.c\nindex 218c30ed3ed..8194a528406 100644\n--- a/builtin/commit-graph.c\n+++ b/builtin/commit-graph.c\n@@ -119,8 +119,8 @@ static int cmd_commit_graph_verify(int argc,\n \tif (!graph)\n \t\treturn 1;\n \n-\tret = verify_commit_graph(graph, flags);\n-\tfree_commit_graph(graph);\n+\tret = commit_graph_verify(graph, flags);\n+\tcommit_graph_free(graph);\n \n \tif (incomplete_chain) {\n \t\terror(\"one or more commit-graph chain files could not be loaded\");\n@@ -324,7 +324,7 @@ static int cmd_commit_graph_write(int argc,\n \t\tstop_progress(&progress);\n \t}\n \n-\tif (write_commit_graph(repo, dir->abspath, &write_opts))\n+\tif (commit_graph_write(repo, dir->abspath, &write_opts))\n \t\tresult = 1;\n \n cleanup:\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 7278cee8ca7..cf8cafc4520 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -2949,7 +2949,7 @@ int cmd_fetch(int argc,\n \t\tif (graph_write_mode != GRAPH_WRITE_SKIP) {\n \t\t\ttrace2_region_enter(\"fetch\", \"write-commit-graph\",\n \t\t\t\t\t    the_repository);\n-\t\t\twrite_commit_graph(the_repository,\n+\t\t\tcommit_graph_write(the_repository,\n \t\t\t\t\t   the_repository->objects->source->path,\n \t\t\t\t\t   &write_opts);\n \t\t\ttrace2_region_leave(\"fetch\", \"write-commit-graph\",\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 7bf88861df0..68cb04a672d 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -741,7 +741,7 @@ int cmd_gc(int argc,\n \t\tif (!opts.quiet && !daemonized)\n \t\t\twrite_opts.flags |= COMMIT_GRAPH_WRITE_PROGRESS;\n \n-\t\twrite_commit_graph(the_repository, the_repository->objects->source->path,\n+\t\tcommit_graph_write(the_repository, the_repository->objects->source->path,\n \t\t\t\t   &write_opts);\n \t}\n \ndiff --git a/commit-graph.c b/commit-graph.c\nindex c82776b0667..da65cd3deb9 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -41,7 +41,7 @@ void git_test_write_commit_graph_or_die(struct repository *repo)\n \tif (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0))\n \t\topts.flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS;\n \n-\tif (write_commit_graph(repo, repo->objects->source->path, &opts))\n+\tif (commit_graph_write(repo, repo->objects->source->path, &opts))\n \t\tdie(\"failed to write commit-graph under GIT_TEST_COMMIT_GRAPH\");\n }\n \n@@ -275,7 +275,7 @@ struct commit_graph *load_commit_graph_one_fd_st(struct repository *repo,\n \tgraph_map = xmmap(NULL, graph_size, PROT_READ, MAP_PRIVATE, fd, 0);\n \tclose(fd);\n \n-\tret = parse_commit_graph(repo, graph_map, graph_size);\n+\tret = commit_graph_parse(repo, graph_map, graph_size);\n \tif (ret)\n \t\tret->dir = absolute_pathdup(dir);\n \telse\n@@ -375,7 +375,7 @@ static int graph_read_bloom_data(const unsigned char *chunk_start,\n \treturn 0;\n }\n \n-struct commit_graph *parse_commit_graph(struct repository *r,\n+struct commit_graph *commit_graph_parse(struct repository *r,\n \t\t\t\t\tvoid *graph_map, size_t graph_size)\n {\n \tconst unsigned char *data;\n@@ -686,7 +686,7 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct object_database *odb,\n \t\t\t\t\tgraph_chain = g;\n \t\t\t\t\tvalid = 1;\n \t\t\t\t} else {\n-\t\t\t\t\tfree_commit_graph(g);\n+\t\t\t\t\tcommit_graph_free(g);\n \t\t\t\t}\n \n \t\t\t\tbreak;\n@@ -830,14 +830,14 @@ struct bloom_filter_settings *get_bloom_filter_settings(struct repository *r)\n \treturn NULL;\n }\n \n-void close_commit_graph(struct object_database *o)\n+void commit_graph_close(struct object_database *o)\n {\n \tif (!o->commit_graph)\n \t\treturn;\n \n \tclear_commit_graph_data_slab(&commit_graph_data_slab);\n \tdeinit_bloom_filters();\n-\tfree_commit_graph(o->commit_graph);\n+\tcommit_graph_free(o->commit_graph);\n \to->commit_graph = NULL;\n }\n \n@@ -2214,7 +2214,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t\tctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2] = new_base_hash;\n \t}\n \n-\tclose_commit_graph(ctx->r->objects);\n+\tcommit_graph_close(ctx->r->objects);\n \tfinalize_hashfile(f, file_hash, FSYNC_COMPONENT_COMMIT_GRAPH,\n \t\t\t  CSUM_HASH_IN_STREAM | CSUM_FSYNC);\n \tfree_chunkfile(cf);\n@@ -2542,7 +2542,7 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)\n \tstrbuf_release(&path);\n }\n \n-int write_commit_graph(struct repository *r,\n+int commit_graph_write(struct repository *r,\n \t\t       const char *dir,\n \t\t       const struct commit_graph_write_options *opts)\n {\n@@ -2904,7 +2904,7 @@ static int verify_one_commit_graph(struct commit_graph *g,\n \treturn verify_commit_graph_error;\n }\n \n-int verify_commit_graph(struct commit_graph *g,\n+int commit_graph_verify(struct commit_graph *g,\n \t\t\tenum commit_graph_verify_flags flags)\n {\n \tstruct progress *progress = NULL;\n@@ -2937,7 +2937,7 @@ int verify_commit_graph(struct commit_graph *g,\n \treturn local_error;\n }\n \n-void free_commit_graph(struct commit_graph *g)\n+void commit_graph_free(struct commit_graph *g)\n {\n \twhile (g) {\n \t\tstruct commit_graph *next = g->base_graph;\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 80d59bd23bd..2156499a688 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -135,9 +135,9 @@ struct repo_settings;\n \n /*\n  * Callers should initialize the repo_settings with prepare_repo_settings()\n- * prior to calling parse_commit_graph().\n+ * prior to calling commit_graph_parse().\n  */\n-struct commit_graph *parse_commit_graph(struct repository *r,\n+struct commit_graph *commit_graph_parse(struct repository *r,\n \t\t\t\t\tvoid *graph_map, size_t graph_size);\n \n /*\n@@ -186,7 +186,7 @@ struct commit_graph_write_options {\n }\n \n /*\n- * The write_commit_graph* methods return zero on success\n+ * The commit_graph_write* methods return zero on success\n  * and a negative value on failure. Note that if the repository\n  * is not compatible with the commit-graph feature, then the\n  * methods will return 0 without writing a commit-graph.\n@@ -195,7 +195,7 @@ struct commit_graph_write_options {\n  * canonicalized internally so that it compares equal to the directory of\n  * graphs that have already been loaded.\n  */\n-int write_commit_graph(struct repository *r,\n+int commit_graph_write(struct repository *r,\n \t\t       const char *dir,\n \t\t       const struct commit_graph_write_options *opts);\n \n@@ -204,11 +204,11 @@ enum commit_graph_verify_flags {\n \tCOMMIT_GRAPH_VERIFY_PROGRESS = (1 << 1),\n };\n \n-int verify_commit_graph(struct commit_graph *g,\n+int commit_graph_verify(struct commit_graph *g,\n \t\t\tenum commit_graph_verify_flags flags);\n \n-void close_commit_graph(struct object_database *);\n-void free_commit_graph(struct commit_graph *);\n+void commit_graph_close(struct object_database *);\n+void commit_graph_free(struct commit_graph *);\n \n /*\n  * Disable further use of the commit graph in this process when parsing a\ndiff --git a/odb.c b/odb.c\nindex 2c93a9490c6..b89457d0c91 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -739,7 +739,7 @@ struct object_database *odb_new(struct repository *repo,\n void odb_close(struct object_database *o)\n {\n \todb_source_close(o->source);\n-\tclose_commit_graph(o);\n+\tcommit_graph_close(o);\n }\n \n static void odb_free_sources(struct object_database *o)\ndiff --git a/oss-fuzz/fuzz-commit-graph.c b/oss-fuzz/fuzz-commit-graph.c\nindex 59bbb849d1e..e941cd9fc56 100644\n--- a/oss-fuzz/fuzz-commit-graph.c\n+++ b/oss-fuzz/fuzz-commit-graph.c\n@@ -23,9 +23,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)\n \tthe_repository->settings.initialized = 1;\n \tthe_repository->settings.commit_graph_generation_version = 2;\n \tthe_repository->settings.commit_graph_changed_paths_version = 1;\n-\tg = parse_commit_graph(the_repository, (void *)data, size);\n+\tg = commit_graph_parse(the_repository, (void *)data, size);\n \trepo_clear(the_repository);\n-\tfree_commit_graph(g);\n+\tcommit_graph_free(g);\n \n \treturn 0;\n }\ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex aceac4f6995..9642e55b8c0 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -119,6 +119,6 @@ int cmd__read_graph(int argc, const char **argv)\n \t}\n \n done:\n-\tfree_commit_graph(graph);\n+\tcommit_graph_free(graph);\n \treturn ret;\n }\n\n-- \n2.56.0.500.g5d06dc02cd.dirty\n\n\n"},{"id":"557461","messageId":"9a97d8ca-e7c9-4e57-905b-109df92a9eae@gmail.com","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-5-d013d9401a59@pks.im","subject":"Re: [PATCH 05/10] commit-graph: merge the two commit graph writers","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-11-04T16:33:11Z","receivedAt":"2026-11-04T16:33:11Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 11/4/2026 10:57 AM, Patrick Steinhardt wrote:\n> We have two entry points for writing commit graphs:\n> \n>   - `write_commit_graph()` either writes a commit graph for all commits\n>     in the object database, or for the commits specified via its options\n>     struct.\n> \n>   - `write_commit_graph_reachable()` writes a commit graph for all\n>     reachable commits.\n> \n> It's somewhat pointless though to have a separate entry point for\n> writing a commit graph for reachable commits, as this use case can be\n> trivially satisfied via a flag.\n> \n> Introduce that flag and drop the separate entry point in favor of\n> `write_commit_graph()`. This ensures we have a single entry point for\n> writing commit graphs, only, which will make it easier to eventually\n> introduce pluggable commit graphs via the object database.\nThe previous four patches were immediately obvious to be correct. This\none takes a little bit more work, but is a valuable simplification\nthat will lead to better code reuse in the future.\n\nThanks,\n-Stolee\n\n\n"},{"id":"557462","messageId":"57322050-95b1-4faf-ae59-30a355d90355@gmail.com","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-6-d013d9401a59@pks.im","subject":"Re: [PATCH 06/10] commit-graph: move remaining write parameters into options","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-11-04T16:34:04Z","receivedAt":"2026-11-04T16:34:04Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 11/4/2026 10:57 AM, Patrick Steinhardt wrote:\n> Move the remaining optional parameters that can be passed to\n> `write_commit_graph()` into its options structure to simplify the\n> function's calling convention.\n\n> -\tif (write_commit_graph(repo, dir->abspath,\n> -\t\t\t       opts.stdin_packs ? &pack_indexes : NULL,\n> -\t\t\t       opts.stdin_commits ? &commits : NULL,\n> -\t\t\t       &write_opts))\n> +\tif (write_commit_graph(repo, dir->abspath, &write_opts))\n>  \t\tresult = 1;\n\nSo much cleaner! (Even better in other hunks.)\n\nThanks,\n-Stolee\n\n\n"},{"id":"557464","messageId":"0e74f6c3-2f43-4829-a071-27e96ab5e87b@gmail.com","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im","subject":"Re: [PATCH 00/10] commit-graph: several refactorings for writing commit graphs","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-11-04T16:37:11Z","receivedAt":"2026-11-04T16:37:11Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 11/4/2026 10:57 AM, Patrick Steinhardt wrote:\n> Hi,\n> \n> this patch series includes several small cleanups for the interfaces for\n> writing commit graphs. Most importantly, the series refactors options so\n> that they all get passed via `struct commit_graph_write_options`. These\n> cleanups are split out of a bigger change to make reading and writing\n> commit-graphs pluggable via the object database bakcend.\nThese cleanups look great. They are carefully constructed to be as\nsimple as possible at each step. It's good to bring some of these\nconventions into a more modern style and to simplify things in the\nprocess.\n\nLGTM.\n\nThanks,\n-Stolee\n\n\n"},{"id":"557472","messageId":"CAL71e4N4BvO=eMfO0wnJ9=gGbfTRz5ayWFZULoN1dGSF7uCZAA@mail.gmail.com","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-6-d013d9401a59@pks.im","subject":"Re: [PATCH 06/10] commit-graph: move remaining write parameters into options","fromName":"Kristofer Karlsson","fromEmail":"krka@spotify.com","sentAt":"2026-11-04T17:49:50Z","receivedAt":"2026-11-04T17:49:50Z","isPatch":true,"sender":{"key":"krka@spotify.com","avatar":"https://avatars.githubusercontent.com/u/5349266?v=4"},"body":"On Wed, 4 Nov 2026 at 17:15, Patrick Steinhardt <ps@pks.im> wrote:\n>\n>                 if (graph_write_mode != GRAPH_WRITE_TIPS)\n>                         write_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;\n> +               else\n> +                       write_opts.commits = &updated_tips;\n\nAh, this touches on my previous patch cef2d8c4cb\n(fetch: write commit-graph using updated refs only, 2026-10-07).\n\nMy only nit would be that the if/else also covers the skip case,\nso one of the branches always fires for it.  A switch would make\neach mode set exactly what it needs:\n\n  switch (graph_write_mode) {\n  case GRAPH_WRITE_SKIP:\n      break;\n  case GRAPH_WRITE_REACHABLE:\n      write_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;\n      break;\n  case GRAPH_WRITE_TIPS:\n      write_opts.commits = &updated_tips;\n      break;\n  }\n\nIt doesn't matter for correctness since the skip case never calls\nthe writer, but it looks easier to reason about to me.\n\nBut that's just a preference, I don't feel strongly about it.\n\n>\n>                 if (graph_write_mode != GRAPH_WRITE_SKIP) {\n>                         trace2_region_enter(\"fetch\", \"write-commit-graph\",\n>                                             the_repository);\n> -                       if (graph_write_mode == GRAPH_WRITE_TIPS)\n> -                               write_commit_graph(\n> -                                       the_repository,\n> -                                       the_repository->objects->source->path,\n> -                                       NULL, &updated_tips, &write_opts);\n> -                       else\n> -                               write_commit_graph(\n> -                                       the_repository,\n> -                                       the_repository->objects->source->path,\n> -                                       NULL, NULL, &write_opts);\n> +                       write_commit_graph(the_repository,\n> +                                          the_repository->objects->source->path,\n> +                                          &write_opts);\n>                         trace2_region_leave(\"fetch\", \"write-commit-graph\",\n>                                             the_repository);\n>                 }\n\nI really like this unification of the call sites and the patch\nlooks great overall!\n\nThanks,\nKristofer\n\n"},{"id":"557492","messageId":"xmqqa4no1k36.fsf@gitster.g","threadId":"66772","inReplyTo":"20261104-pks-commit-graph-write-refactorings-v1-4-d013d9401a59@pks.im","subject":"Re: [PATCH 04/10] commit-graph: drop redundant flags in write context","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-04T19:18:37Z","receivedAt":"2026-11-04T19:18:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> In the preceding commit we have moved the flags that control how we\n> write a commit graph into its options structure. As a consequence we\n> have those flags implicitly available in the write context, too, as it\n> already contains a pointer to the options struct. This makes a couple of\n> individual flags that we track in the write context redundant as they\n> are a simple alias of the flags.\n>\n> Drop these redundant flags.\n> ...\n>  \tstruct write_commit_graph_context ctx = {\n>  \t\t.r = r,\n> -\t\t.append = opts->flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0,\n> -\t\t.report_progress = opts->flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0,\n> -\t\t.split = opts->flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,\n\nOK, so these are the most important lines in this patch; everything\nelse is there as a fallout of this change, and as a result, the\nremaining code has become much easier to follow.\n\nNicely done.\n\n"},{"id":"557542","messageId":"auyCsmn6Hx_uc6zq@pks.im","threadId":"66772","inReplyTo":"CAL71e4N4BvO=eMfO0wnJ9=gGbfTRz5ayWFZULoN1dGSF7uCZAA@mail.gmail.com","subject":"Re: [PATCH 06/10] commit-graph: move remaining write parameters into options","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-05T13:20:50Z","receivedAt":"2026-11-05T13:20:50Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Nov 04, 2026 at 06:49:50PM +0100, Kristofer Karlsson wrote:\n> On Wed, 4 Nov 2026 at 17:15, Patrick Steinhardt <ps@pks.im> wrote:\n> >\n> >                 if (graph_write_mode != GRAPH_WRITE_TIPS)\n> >                         write_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;\n> > +               else\n> > +                       write_opts.commits = &updated_tips;\n> \n> Ah, this touches on my previous patch cef2d8c4cb\n> (fetch: write commit-graph using updated refs only, 2026-10-07).\n> \n> My only nit would be that the if/else also covers the skip case,\n> so one of the branches always fires for it.  A switch would make\n> each mode set exactly what it needs:\n> \n>   switch (graph_write_mode) {\n>   case GRAPH_WRITE_SKIP:\n>       break;\n>   case GRAPH_WRITE_REACHABLE:\n>       write_opts.flags |= COMMIT_GRAPH_WRITE_REACHABLE;\n>       break;\n>   case GRAPH_WRITE_TIPS:\n>       write_opts.commits = &updated_tips;\n>       break;\n>   }\n> \n> It doesn't matter for correctness since the skip case never calls\n> the writer, but it looks easier to reason about to me.\n> \n> But that's just a preference, I don't feel strongly about it.\n\nI was wondering whether we want to maybe introduce a tagged union where\nit becomes implicitly clear that some of the options only apply to a\nspecific mode. Something like this:\n\ndiff --git a/commit-graph.h b/commit-graph.h\nindex 2156499a688..8d53f80f179 100644\n--- a/commit-graph.h\n+++ b/commit-graph.h\n@@ -160,7 +160,6 @@ enum commit_graph_write_flags {\n \tCOMMIT_GRAPH_WRITE_SPLIT      = (1 << 2),\n \tCOMMIT_GRAPH_WRITE_BLOOM_FILTERS = (1 << 3),\n \tCOMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS = (1 << 4),\n-\tCOMMIT_GRAPH_WRITE_REACHABLE  = (1 << 5),\n };\n \n enum commit_graph_split_flags {\n@@ -170,9 +169,18 @@ enum commit_graph_split_flags {\n };\n \n struct commit_graph_write_options {\n+\tenum commit_graph_write_mode {\n+\t\tCOMMIT_GRAPH_WRITE_ALL,\n+\t\tCOMMIT_GRAPH_WRITE_REACHABLE,\n+\t\tCOMMIT_GRAPH_WRITE_PACKS_INDEXES,\n+\t\tCOMMIT_GRAPH_WRITE_COMMITS,\n+\t} mode;\n+\tunion {\n+\t\tconst struct string_list *pack_indexes;\n+\t\tstruct oidset *commits;\n+\t} mode_args;\n+\n \tenum commit_graph_write_flags flags;\n-\tconst struct string_list *pack_indexes;\n-\tstruct oidset *commits;\n \tint size_multiple;\n \tint max_commits;\n \ttimestamp_t expire_time;\n\nI wasn't really sure whether that complexity is really worth it, so for\nnow I decided to not pursue it. I think I still tend to stick with that\ndecision for now, but it's maybe something to keep in mind for the\nfuture?\n\nPatrick\n\n"},{"id":"557545","messageId":"auyKxKX4l3QmGG1y@pks.im","threadId":"66772","inReplyTo":"0e74f6c3-2f43-4829-a071-27e96ab5e87b@gmail.com","subject":"Re: [PATCH 00/10] commit-graph: several refactorings for writing commit graphs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-05T13:55:16Z","receivedAt":"2026-11-05T13:55:16Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Nov 04, 2026 at 11:37:11AM -0500, Derrick Stolee wrote:\n> On 11/4/2026 10:57 AM, Patrick Steinhardt wrote:\n> > Hi,\n> > \n> > this patch series includes several small cleanups for the interfaces for\n> > writing commit graphs. Most importantly, the series refactors options so\n> > that they all get passed via `struct commit_graph_write_options`. These\n> > cleanups are split out of a bigger change to make reading and writing\n> > commit-graphs pluggable via the object database bakcend.\n> These cleanups look great. They are carefully constructed to be as\n> simple as possible at each step. It's good to bring some of these\n> conventions into a more modern style and to simplify things in the\n> process.\n\nThanks for your review!\n\nPatrick\n\n"},{"id":"557547","messageId":"auyLRZ8TWeqdIaRm@pks.im","threadId":"66772","inReplyTo":"0e74f6c3-2f43-4829-a071-27e96ab5e87b@gmail.com","subject":"Re: [PATCH 00/10] commit-graph: several refactorings for writing commit graphs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-05T13:57:25Z","receivedAt":"2026-11-05T13:57:25Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Nov 04, 2026 at 11:37:11AM -0500, Derrick Stolee wrote:\n> On 11/4/2026 10:57 AM, Patrick Steinhardt wrote:\n> > Hi,\n> > \n> > this patch series includes several small cleanups for the interfaces for\n> > writing commit graphs. Most importantly, the series refactors options so\n> > that they all get passed via `struct commit_graph_write_options`. These\n> > cleanups are split out of a bigger change to make reading and writing\n> > commit-graphs pluggable via the object database bakcend.\n> These cleanups look great. They are carefully constructed to be as\n> simple as possible at each step. It's good to bring some of these\n> conventions into a more modern style and to simplify things in the\n> process.\n\nAh, by the way, one thing I forgot: I noticed this recently already, but\nyou don't reply-to-all and thus lose the Cc's on your replies. That made\nme miss a couple of your replies already, so I'd appreciate it if you\ncould keep them.\n\nThanks!\n\nPatrick\n\n"},{"id":"557564","messageId":"CAL71e4PxNKffAmmB2XbV8mksUe_nJ9uS2JQhpbm2X1jtG=z9SQ@mail.gmail.com","threadId":"66772","inReplyTo":"auyCsmn6Hx_uc6zq@pks.im","subject":"Re: [PATCH 06/10] commit-graph: move remaining write parameters into options","fromName":"Kristofer Karlsson","fromEmail":"krka@spotify.com","sentAt":"2026-11-05T15:07:18Z","receivedAt":"2026-11-05T15:07:18Z","isPatch":true,"sender":{"key":"krka@spotify.com","avatar":"https://avatars.githubusercontent.com/u/5349266?v=4"},"body":"On Thu, 5 Nov 2026 at 14:21, Patrick Steinhardt <ps@pks.im> wrote:\n>\n> I was wondering whether we want to maybe introduce a tagged union where\n> it becomes implicitly clear that some of the options only apply to a\n> specific mode. Something like this:\n>\n[...]\n>\n> I wasn't really sure whether that complexity is really worth it, so for\n> now I decided to not pursue it. I think I still tend to stick with that\n> decision for now, but it's maybe something to keep in mind for the\n> future?\n\nYes, I agree that it's already clean enough.  If this code ever\nmoves to Rust, an enum with the relevant data would be nice though.\n\nThanks,\nKristofer\n\n"},{"id":"557566","messageId":"ca5986e3-8f66-4628-9f06-eb2416378bef@gmail.com","threadId":"66772","inReplyTo":"auyLRZ8TWeqdIaRm@pks.im","subject":"Re: [PATCH 00/10] commit-graph: several refactorings for writing commit graphs","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2026-11-05T15:18:51Z","receivedAt":"2026-11-05T15:18:51Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 11/5/2026 8:57 AM, Patrick Steinhardt wrote:\n> On Wed, Nov 04, 2026 at 11:37:11AM -0500, Derrick Stolee wrote:\n>> On 11/4/2026 10:57 AM, Patrick Steinhardt wrote:\n>>> Hi,\n>>>\n>>> this patch series includes several small cleanups for the interfaces for\n>>> writing commit graphs. Most importantly, the series refactors options so\n>>> that they all get passed via `struct commit_graph_write_options`. These\n>>> cleanups are split out of a bigger change to make reading and writing\n>>> commit-graphs pluggable via the object database bakcend.\n>> These cleanups look great. They are carefully constructed to be as\n>> simple as possible at each step. It's good to bring some of these\n>> conventions into a more modern style and to simplify things in the\n>> process.\n> \n> Ah, by the way, one thing I forgot: I noticed this recently already, but\n> you don't reply-to-all and thus lose the Cc's on your replies. That made\n> me miss a couple of your replies already, so I'd appreciate it if you\n> could keep them.\nSorry about that. I learned that Thunderbird replaced the \"Reply All\"\nbutton with a \"Reply List\" button that led to this unintentional\nbehavior. I'll figure out how to change that default.\n\nThanks,\n-Stolee\n\n\n"},{"id":"557575","messageId":"auyhxtMFUwrDJdHT@pks.im","threadId":"66772","inReplyTo":"ca5986e3-8f66-4628-9f06-eb2416378bef@gmail.com","subject":"Re: [PATCH 00/10] commit-graph: several refactorings for writing commit graphs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-05T15:33:26Z","receivedAt":"2026-11-05T15:33:26Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, Nov 05, 2026 at 10:18:51AM -0500, Derrick Stolee wrote:\n> On 11/5/2026 8:57 AM, Patrick Steinhardt wrote:\n> > On Wed, Nov 04, 2026 at 11:37:11AM -0500, Derrick Stolee wrote:\n> >> On 11/4/2026 10:57 AM, Patrick Steinhardt wrote:\n> >>> Hi,\n> >>>\n> >>> this patch series includes several small cleanups for the interfaces for\n> >>> writing commit graphs. Most importantly, the series refactors options so\n> >>> that they all get passed via `struct commit_graph_write_options`. These\n> >>> cleanups are split out of a bigger change to make reading and writing\n> >>> commit-graphs pluggable via the object database bakcend.\n> >> These cleanups look great. They are carefully constructed to be as\n> >> simple as possible at each step. It's good to bring some of these\n> >> conventions into a more modern style and to simplify things in the\n> >> process.\n> > \n> > Ah, by the way, one thing I forgot: I noticed this recently already, but\n> > you don't reply-to-all and thus lose the Cc's on your replies. That made\n> > me miss a couple of your replies already, so I'd appreciate it if you\n> > could keep them.\n> Sorry about that. I learned that Thunderbird replaced the \"Reply All\"\n> button with a \"Reply List\" button that led to this unintentional\n> behavior. I'll figure out how to change that default.\n\nThe joy of random UI updates.\n\nPatrick\n\n"}]}