Re: [PATCH v3 2/2] fetch: write commit-graph using updated refs only
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Oct 8, 2026, 06:01 UTC
- Message-ID
- <ascxqBn0RsXnLWSp@pks.im>
- In-Reply-To
- <01da9857bcd847bec4eb85d8f57ea1cdc40b1758.1791382977.git.gitgitgadget@gmail.com>
On Wed, Oct 07, 2026 at 02:22:57PM +0000, Kristofer Karlsson via GitGitGadget wrote:
Show 29 quoted lines
> From: Kristofer Karlsson <krka@spotify.com> > > When fetch.writeCommitGraph was introduced in 50f26bd035 (fetch: add > fetch.writeCommitGraph config setting, 2019-09-02), the stated goal > was to stay updated with the latest commits after fetching new > objects. The implementation used write_commit_graph_reachable() > because it was the only API available, but two things have changed > since then: > > 1. write_commit_graph() was added, and it accepts an explicit set of > commits as seeds, enabling more targeted commit-graph updates. > > 2. The ref-scanning callback add_ref_to_set() became more expensive > in 630cd5194e (commit-graph.c: peel refs in 'add_ref_to_set', > 2020-07-22) when it started to validate the refs against the odb > for correctness. On a repository with many refs, this makes the > full reachable scan unnecessarily costly for a targeted fetch. > > Optimize the commit-graph write by using only the newly updated refs > as seeds instead of scanning all refs after every fetch. To keep > this change small, skip the optimization for multi-remote fetches > (since that would require propagating the set of refs across process > boundaries). > > This relies on the commit-graph write being additive, keeping the > commits that are already in the graph. fetch already operates in > this mode (COMMIT_GRAPH_WRITE_SPLIT) and now that becomes > required for correctness. Without that mode, the write would > replace the commit-graph and lose other commits.
Everything from here...
Show 20 quoted lines
> After fetch_one() returns, call prepare_commit_graph() (which is > made non-static by this commit) to determine the graph-write mode: > > - If no commit-graph exists yet, fall back to the full reachable > scan so the first graph creation covers all refs. > > - If a commit-graph exists and the fetch updated at least one ref, > write incrementally using only the new refs as seeds. > > - If a commit-graph exists but the fetch is a no-op, skip the > commit-graph write entirely. > > - For the multi-remote path (fetch --all), where child processes > do the actual fetching, fall back to the full reachable scan. > > Full commit-graph coverage of all refs remains the responsibility > of "git maintenance", "git gc" and "git commit-graph write". > Regular Git operations may trigger "git maintenance run --auto", > which periodically rebuilds the commit-graph from all reachable > refs.
... to here is still overly verbose, especially the last paragraph. But I haven't been complaining about that in the last round, and the rest reads significantly better now. So this is not worth another reroll, if you ask me.
Other than that I'm happy with this series now, thanks!
Patrick