Skip to content

Commit 2dd804c

Browse files
ttaylorrgitster
authored andcommitted
t5318: demonstrate commit-graph generation v2 corruption
When upgrading a commit-graph using generation v1 to one using generation v2, it is possible to force Git into a corrupt state where it (incorrectly) believes that a GDO2 chunk is necessary, *after* deciding not to write one. This makes subsequent reads using the commit-graph produce the following error message: fatal: commit-graph requires overflow generation data but has none Demonstrate this bug by increasing our test coverage to include a minimal example of upgrading a commit-graph from generation v1 to v2. The only notable components of this test are: - The committer date of the commit is chosen carefully so that the offset underflows when computed using a v1 generation number, but would not overflow when using v2 generation numbers. - The upgrade to generation number v2 must read in the v1 generation numbers, which we can do by passing `--changed-paths`, which will force the commit-graph internals to call `fill_commit_graph_info()`. A future patch will squash this bug. Reported-by: Jeff King <[email protected]> Reproduced-by: Will Chandler <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6cd33dc commit 2dd804c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

t/t5318-commit-graph.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,4 +811,31 @@ test_expect_success 'set up and verify repo with generation data overflow chunk'
811811

812812
graph_git_behavior 'generation data overflow chunk repo' repo left right
813813

814+
test_expect_failure 'overflow during generation version upgrade' '
815+
git init overflow-v2-upgrade &&
816+
(
817+
cd overflow-v2-upgrade &&
818+
819+
# This commit will have a date at two seconds past the Epoch,
820+
# and a (v1) generation number of 1, since it is a root commit.
821+
#
822+
# The offset will then be computed as 1-2, which will underflow
823+
# to 2^31, which is greater than the v2 offset small limit of
824+
# 2^31-1.
825+
#
826+
# This is sufficient to need a large offset table for the v2
827+
# generation numbers.
828+
test_commit --date "@2 +0000" base &&
829+
git repack -d &&
830+
831+
# Test that upgrading from generation v1 to v2 correctly
832+
# produces the overflow table.
833+
git -c commitGraph.generationVersion=1 commit-graph write &&
834+
git -c commitGraph.generationVersion=2 commit-graph write \
835+
--changed-paths &&
836+
837+
git rev-list --all
838+
)
839+
'
840+
814841
test_done

0 commit comments

Comments
 (0)