]> git.ipfire.org Git - thirdparty/git.git/commit - commit-graph.c
commit-graph: be extra careful about mixed generations
authorDerrick Stolee <dstolee@microsoft.com>
Tue, 2 Feb 2021 03:01:22 +0000 (03:01 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Feb 2021 05:03:36 +0000 (21:03 -0800)
commitfde55b0906552537c8cbcbf654f8e9dd64414637
tree495174c91dc78a480a2abc0b3bdd8b37c36156cf
parent9c2c0a82560a49b6b491a88cbaeaaf30378ec6bb
commit-graph: be extra careful about mixed generations

When upgrading to a commit-graph with corrected commit dates from
one without, there are a few things that need to be considered.

When computing generation numbers for the new commit-graph file that
expects to add the generation_data chunk with corrected commit
dates, we need to ensure that the 'generation' member of the
commit_graph_data struct is set to zero for these commits.

Unfortunately, the fallback to use topological level for generation
number when corrected commit dates are not available are causing us
harm here: parsing commits notices that read_generation_data is
false and populates 'generation' with the topological level.

The solution is to iterate through the commits, parse the commits
to populate initial values, then reset the generation values to
zero to trigger recalculation. This loop only occurs when the
existing commit-graph data has no corrected commit dates.

While this improves our situation somewhat, we have not completely
solved the issue for correctly computing generation numbers for mixed
layers. That follows in the next change.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c