git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 01/10] commit-graph: rename `struct commit_graph_opts`

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 4, 2026, 15:57 UTC
Message-ID
<20261104-pks-commit-graph-write-refactorings-v1-1-d013d9401a59@pks.im>
In-Reply-To
<20261104-pks-commit-graph-write-refactorings-v1-0-d013d9401a59@pks.im>

The `struct commit_graph_opts` is used by us to control how exactly a commit graph gets written. Nothing really indicates that it's only intended for use by `write_commit_graph()` though.

Rename it to `struct commit_graph_write_options` to fix that. Note that in a subsequent commit we'll also rename `write_commit_graph()` to `commit_graph_write()` to match our modern best practices for naming, and that will align the naming for both of these.

While at it, also introduce an `INIT` macro.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/commit-graph.c |  7 ++-----
 commit-graph.c         |  6 +++---
 commit-graph.h         | 11 ++++++++---
 3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 4d28a9d51ec..0445302ba8b 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -141,7 +141,7 @@ static int cmd_commit_graph_verify(int argc,
 }
 
 struct commit_graph_write_config_data {
-	struct commit_graph_opts *write_opts;
+	struct commit_graph_write_options *write_opts;
 	struct opts_commit_graph *opts;
 };
 
@@ -229,10 +229,7 @@ static int cmd_commit_graph_write(int argc,
 				  const char *prefix,
 				  struct repository *repo)
 {
-	struct commit_graph_opts write_opts = {
-		.size_multiple = 2,
-		.max_new_filters = -1,
-	};
+	struct commit_graph_write_options write_opts = COMMIT_GRAPH_WRITE_OPTIONS_INIT;
 	struct opts_commit_graph opts = {
 		.progress = isatty(2),
 		.enable_changed_paths = -1,
diff --git a/commit-graph.c b/commit-graph.c
index 6c141a6555f..2f9bf7a44fd 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1166,7 +1166,7 @@ struct write_commit_graph_context {
 		 trust_generation_numbers:1;
 
 	struct topo_level_slab *topo_levels;
-	const struct commit_graph_opts *opts;
+	const struct commit_graph_write_options *opts;
 	size_t total_bloom_filter_data_size;
 	const struct bloom_filter_settings *bloom_settings;
 
@@ -1916,7 +1916,7 @@ static int add_ref_to_set(const struct reference *ref, void *cb_data)
 int write_commit_graph_reachable(struct repository *repo,
 				 const char *dir,
 				 enum commit_graph_write_flags flags,
-				 const struct commit_graph_opts *opts)
+				 const struct commit_graph_write_options *opts)
 {
 	struct oidset commits = OIDSET_INIT;
 	struct refs_cb_data data;
@@ -2565,7 +2565,7 @@ int write_commit_graph(struct repository *r,
 		       const struct string_list *const pack_indexes,
 		       struct oidset *commits,
 		       enum commit_graph_write_flags flags,
-		       const struct commit_graph_opts *opts)
+		       const struct commit_graph_write_options *opts)
 {
 	struct write_commit_graph_context ctx = {
 		.r = r,
diff --git a/commit-graph.h b/commit-graph.h
index 3b55192c2a1..513713ecb62 100644
--- a/commit-graph.h
+++ b/commit-graph.h
@@ -168,7 +168,7 @@ enum commit_graph_split_flags {
 	COMMIT_GRAPH_SPLIT_REPLACE          = 2
 };
 
-struct commit_graph_opts {
+struct commit_graph_write_options {
 	int size_multiple;
 	int max_commits;
 	timestamp_t expire_time;
@@ -176,6 +176,11 @@ struct commit_graph_opts {
 	int max_new_filters;
 };
 
+#define COMMIT_GRAPH_WRITE_OPTIONS_INIT { \
+	.size_multiple = 2, \
+	.max_new_filters = -1, \
+}
+
 /*
  * The write_commit_graph* methods return zero on success
  * and a negative value on failure. Note that if the repository
@@ -189,13 +194,13 @@ struct commit_graph_opts {
 int write_commit_graph_reachable(struct repository *repo,
 				 const char *dir,
 				 enum commit_graph_write_flags flags,
-				 const struct commit_graph_opts *opts);
+				 const struct commit_graph_write_options *opts);
 int write_commit_graph(struct repository *r,
 		       const char *dir,
 		       const struct string_list *pack_indexes,
 		       struct oidset *commits,
 		       enum commit_graph_write_flags flags,
-		       const struct commit_graph_opts *opts);
+		       const struct commit_graph_write_options *opts);
 
 #define COMMIT_GRAPH_VERIFY_SHALLOW	(1 << 0)
 
-- 
2.56.0.500.g5d06dc02cd.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 2 of 22 in “commit-graph: several refactorings for writing commit graphs”
  1. 00/10 commit-graph: several refactorings for writing commit graphsPatrick Steinhardt, Nov 4, 2026
  2. 01/10 commit-graph: rename `struct commit_graph_opts`Patrick Steinhardt, Nov 4, 2026
  3. 02/10 commit-graph: pass writer flags via optionsPatrick Steinhardt, Nov 4, 2026
  4. 03/10 commit-graph: drop `NULL` checks for write optionsPatrick Steinhardt, Nov 4, 2026
  5. 04/10 commit-graph: drop redundant flags in write contextPatrick Steinhardt, Nov 4, 2026
  6. Junio C HamanoNov 4, 2026
  7. 05/10 commit-graph: merge the two commit graph writersPatrick Steinhardt, Nov 4, 2026
  8. Derrick StoleeNov 4, 2026
  9. 06/10 commit-graph: move remaining write parameters into optionsPatrick Steinhardt, Nov 4, 2026
  10. Derrick StoleeNov 4, 2026
  11. Kristofer KarlssonNov 4, 2026
  12. Patrick SteinhardtNov 5, 2026
  13. Kristofer KarlssonNov 5, 2026
  14. 07/10 commit-graph: fix mixup of write/verify flagsPatrick Steinhardt, Nov 4, 2026
  15. 08/10 builtin/commit-graph: set flags directlyPatrick Steinhardt, Nov 4, 2026
  16. 09/10 odb/source-files: verify commit-graphs as part of fsckPatrick Steinhardt, Nov 4, 2026
  17. 10/10 commit-graph: modernize function namesPatrick Steinhardt, Nov 4, 2026
  18. Derrick StoleeNov 4, 2026
  19. Patrick SteinhardtNov 5, 2026
  20. Patrick SteinhardtNov 5, 2026
  21. Derrick StoleeNov 5, 2026
  22. Patrick SteinhardtNov 5, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.