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

[PATCH 09/12] commit-graph: mark incomplete commit graph chains

From
Patrick Steinhardt <ps@pks.im>
Date
Nov 16, 2026, 13:07 UTC
Message-ID
<20261116-pks-odb-pluggable-commit-graphs-v1-9-a83fc1ff0808@pks.im>
In-Reply-To
<20261116-pks-odb-pluggable-commit-graphs-v1-0-a83fc1ff0808@pks.im>

When loading a commit graph chain it may happen that we only find a subset of its layers. Such a commit graph is still usable though in the case where we have the base and layers building on top of it, so we still return such an incomplete commit graph to the caller.

While valid and usable, we of course want to warn about such commit graphs in `git commit-graph verify`, which is why there is an `incomplete` out-parameter in `load_commit_graph_chain_fd_st()`. In a subsequent commit though we want to hide this function in favor of a pluggable interface, but carrying such a flag there feels wrong.

Instead, have the function set a new `incomplete` field in the commit graph structure itself.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/commit-graph.c | 9 ++++-----
 commit-graph.c         | 9 ++++-----
 commit-graph.h         | 4 ++--
 3 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 2a5a75dc22f..5ecce4b6caa 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -66,7 +66,6 @@ static int cmd_commit_graph_verify(int argc,
 	enum commit_graph_verify_flags flags = isatty(2) ? COMMIT_GRAPH_VERIFY_PROGRESS : 0;
 	int fd;
 	struct stat st;
-	int incomplete_chain = 0;
 	int ret;
 	struct option options[] = {
 		OPT_BIT(0, "shallow", &flags,
@@ -113,20 +112,20 @@ static int cmd_commit_graph_verify(int argc,
 	else if (opened == OPENED_GRAPH)
 		graph = commit_graph_read(repo, fd, &st);
 	else
-		graph = load_commit_graph_chain_fd_st(repo->objects, fd, &st,
-						      &incomplete_chain);
+		graph = load_commit_graph_chain_fd_st(repo->objects, fd, &st);
 
 	if (!graph)
 		return 1;
 
 	ret = commit_graph_verify(graph, flags);
-	commit_graph_free(graph);
 
-	if (incomplete_chain) {
+	if (graph->incomplete) {
 		error("one or more commit-graph chain files could not be loaded");
 		ret |= 1;
 	}
 
+	commit_graph_free(graph);
+
 	return ret;
 }
 
diff --git a/commit-graph.c b/commit-graph.c
index 7bb6b112b2e..0ae9f586f21 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -651,8 +651,7 @@ int open_commit_graph_chain(const char *chain_file,
 }
 
 struct commit_graph *load_commit_graph_chain_fd_st(struct object_database *odb,
-						   int fd, struct stat *st,
-						   int *incomplete_chain)
+						   int fd, struct stat *st)
 {
 	struct commit_graph *graph_chain = NULL;
 	struct strbuf line = STRBUF_INIT;
@@ -703,11 +702,12 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct object_database *odb,
 	}
 
 	commit_graph_validate_chain(graph_chain);
+	if (graph_chain)
+		graph_chain->incomplete = !valid;
 
 	fclose(fp);
 	strbuf_release(&line);
 
-	*incomplete_chain = !valid;
 	return graph_chain;
 }
 
@@ -720,9 +720,8 @@ static struct commit_graph *load_commit_graph_chain(struct repository *repo,
 	struct commit_graph *g = NULL;
 
 	if (open_commit_graph_chain(chain_file, &fd, &st, repo->hash_algo)) {
-		int incomplete;
 		/* ownership of fd is taken over by load function */
-		g = load_commit_graph_chain_fd_st(repo->objects, fd, &st, &incomplete);
+		g = load_commit_graph_chain_fd_st(repo->objects, fd, &st);
 	}
 
 	free(chain_file);
diff --git a/commit-graph.h b/commit-graph.h
index 1cc0d097321..3b5e0eb2d73 100644
--- a/commit-graph.h
+++ b/commit-graph.h
@@ -93,6 +93,7 @@ struct commit_graph {
 	struct object_id oid;
 	char *dir;
 	char *filename;
+	bool incomplete;
 
 	uint32_t num_commits_in_base;
 	unsigned int read_generation_data;
@@ -124,8 +125,7 @@ struct commit_graph {
 struct commit_graph *commit_graph_read(struct repository *repo,
 				       int fd, struct stat *st);
 struct commit_graph *load_commit_graph_chain_fd_st(struct object_database *odb,
-						   int fd, struct stat *st,
-						   int *incomplete_chain);
+						   int fd, struct stat *st);
 
 /*
  * Link the commit graph layer `g` on top of the chain `base`. `base` may be
-- 
2.56.1.763.g16177fe143.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 11 of 14 in “Introduce pluggable commit graphs”
  1. 00/12 Introduce pluggable commit graphsPatrick Steinhardt, Nov 16, 2026
  2. 01/12 commit-graph: simplify linking commit graph chainsPatrick Steinhardt, Nov 16, 2026
  3. Junio C HamanoNov 16, 2026
  4. 02/12 commit-graph: simplify reading a single commit graphPatrick Steinhardt, Nov 16, 2026
  5. 03/12 commit-graph: expose function to validate a commit graph chainPatrick Steinhardt, Nov 16, 2026
  6. 04/12 commit-graph: decide mergeable and chainable layers by depthPatrick Steinhardt, Nov 16, 2026
  7. 05/12 commit-graph: introduce common exit for `write_commit_graph_file()`Patrick Steinhardt, Nov 16, 2026
  8. 06/12 commit-graph: derive layer infos from the passed-in chainPatrick Steinhardt, Nov 16, 2026
  9. 07/12 commit-graph: split out check whether writing commit graphs is allowedPatrick Steinhardt, Nov 16, 2026
  10. 08/12 commit-graph: split out logic to write a new commit graph layerPatrick Steinhardt, Nov 16, 2026
  11. 09/12 commit-graph: mark incomplete commit graph chainsPatrick Steinhardt, Nov 16, 2026
  12. 10/12 odb/source: make commit graphs pluggablePatrick Steinhardt, Nov 16, 2026
  13. 11/12 odb/source-files: move logic to derive commit graph pathsPatrick Steinhardt, Nov 16, 2026
  14. 12/12 odb/source-files: internalize logic to derive commit graph pathsPatrick Steinhardt, Nov 16, 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.