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

Re: [PATCH] commit: fall back to full read when maybe_tree is NULL

From
RVRasmus Villemoes <ravi@prevas.dk>
Date
May 19, 2026, 06:25 UTC
Message-ID
<87o6ibex0u.fsf@prevas.dk>
In-Reply-To
<20260519050513.GA1635924@coredump.intra.peff.net>
On Tue, May 19 2026, Jeff King <peff@peff.net> wrote:
Show 30 quoted lines
> When we load a commit object from the commit graph (rather than reading
> the object contents), we don't fill in its "maybe_tree" entry, but
> rather wait to lazy-load it. This goes back to 7b8a21dba1 (commit-graph:
> lazy-load trees for commits, 2018-04-06), and saves the work of
> instantiating tree objects that nobody cares about.
>
> But it creates a data dependency: now the commit struct depends on the
> graph file to do that lazy load. This is a problem if we close the graph
> file; now we have a commit struct that claims to be parsed but is
> missing some of its data.
>
> It's rare for this to be a problem in practice, because we don't tend to
> close the graph files at all, and if we do we don't tend to look at
> their commits afterward. But there is one case that is easy to trigger:
> git-clone's --dissociate option will close the object database before
> running the dissociate repack, and then afterwards still try to check
> out the working tree. This will yield an error like:
>
>   fatal: unable to parse commit b29edc0babef41810f7b1c9ee1d74058f22e4080
>   warning: Clone succeeded, but checkout failed.
>
> What happens is that we expect repo_get_commit_tree() to lazy-load the
> tree, but commit_graph_position() returns COMMIT_NOT_FROM_GRAPH because
> the position slab has gone away (and even if it hadn't, we don't have
> the graph file itself available anymore).
>
> Let's try harder to find the tree in repo_get_commit_tree() by actually
> opening the commit object and parsing the tree line. This is extra work,
> but no more than we'd have to go to if we hadn't done the initial graph
> load in the first place.

I can confirm that this, applied on top of v2.54.0, fixes the problem for the instance I had.

Tested-by: Rasmus Villemoes <ravi@prevas.dk>

Thanks, Rasmus

Previous: Derrick StoleeNext: Derrick Stolee
Message 5 of 6 in “commit: fall back to full read when maybe_tree is NULL”
  1. commit: fall back to full read when maybe_tree is NULLJeff King, May 19, 2026
  2. Junio C HamanoMay 19, 2026
  3. Jeff KingMay 19, 2026
  4. Derrick StoleeMay 20, 2026
  5. Rasmus VillemoesMay 19, 2026
  6. Derrick StoleeMay 20, 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.