Skip to content

git: Enable reading and writing commit-graph generation data

The commit-graph data structure is used to speed up various different queries that would normally require us to parse a Git commit from its object representation. One of the things it speeds up is the question whether a certain commit can in fact be reachable by another commit.

This is done by computing a so-called corrected committer date, or generation number. The generation number is calculated as the maximum of the current commit's committer time or any of the parent's generation numbers. As such it is trivial to say if any commit has a generation number greater than the generation of a different commit, that it cannot ever be reached by it.

Being able to speed up reachability checks with this generation number is an important optimization especially in the context of packfile negotiation, where we need to check whether a specific Git commit would already be reachable by a set of announced references or not.

Right now we explicitly disable both reading and writing generation numbers by setting the unintuitive commitGraph.generationVersion=1. This had to be done because a patch series that fixed several bugs in the context of commit-graphs introduced with Git v2.36.0 actually uncovered a different bug that caused corruption when upgrading graphs that contained a v1 generation data.

This source of corruption was finally fixed in 9550f6c16a (commit-graph: fix corrupt upgrade from generation v1 to v2, 2022-07-12), which is contained in Git v2.37.2 and newer.

Closes #4691 (closed).

Edited by Patrick Steinhardt

Merge request reports