blob: fc6a242b56d88686036ff019003352ee806ef8ce [file] [log] [blame]
Derrick Stolee75979d92022-03-01 19:48:30 +00001#!/bin/sh
2
3test_description='commit graph with 64-bit timestamps'
Jeff Kingd9c84c62023-10-03 16:31:11 -04004
5TEST_PASSES_SANITIZE_LEAK=true
Derrick Stolee75979d92022-03-01 19:48:30 +00006. ./test-lib.sh
7
8if ! test_have_prereq TIME_IS_64BIT || ! test_have_prereq TIME_T_IS_64BIT
9then
10 skip_all='skipping 64-bit timestamp tests'
11 test_done
12fi
13
14. "$TEST_DIRECTORY"/lib-commit-graph.sh
Jeff Kingee6a7922023-10-09 17:05:47 -040015. "$TEST_DIRECTORY/lib-chunk.sh"
Derrick Stolee75979d92022-03-01 19:48:30 +000016
17UNIX_EPOCH_ZERO="@0 +0000"
18FUTURE_DATE="@4147483646 +0000"
19
20GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0
21
22test_expect_success 'lower layers have overflow chunk' '
23 rm -f .git/objects/info/commit-graph &&
24 test_commit --date "$FUTURE_DATE" future-1 &&
25 test_commit --date "$UNIX_EPOCH_ZERO" old-1 &&
26 git commit-graph write --reachable &&
27 test_commit --date "$FUTURE_DATE" future-2 &&
28 test_commit --date "$UNIX_EPOCH_ZERO" old-2 &&
29 git commit-graph write --reachable --split=no-merge &&
30 test_commit extra &&
31 git commit-graph write --reachable --split=no-merge &&
32 git commit-graph write --reachable &&
33 graph_read_expect 5 "generation_data generation_data_overflow" &&
34 mv .git/objects/info/commit-graph commit-graph-upgraded &&
35 git commit-graph write --reachable &&
36 graph_read_expect 5 "generation_data generation_data_overflow" &&
37 test_cmp .git/objects/info/commit-graph commit-graph-upgraded
38'
39
40graph_git_behavior 'overflow' '' HEAD~2 HEAD
41
Derrick Stoleec8d67b92022-03-01 19:48:32 +000042test_expect_success 'set up and verify repo with generation data overflow chunk' '
Taylor Blau749f1262023-07-24 12:39:31 -040043 git init repo &&
44 (
45 cd repo &&
46 test_commit --date "$UNIX_EPOCH_ZERO" 1 &&
47 test_commit 2 &&
48 test_commit --date "$UNIX_EPOCH_ZERO" 3 &&
49 git commit-graph write --reachable &&
50 graph_read_expect 3 generation_data &&
51 test_commit --date "$FUTURE_DATE" 4 &&
52 test_commit 5 &&
53 test_commit --date "$UNIX_EPOCH_ZERO" 6 &&
54 git branch left &&
55 git reset --hard 3 &&
56 test_commit 7 &&
57 test_commit --date "$FUTURE_DATE" 8 &&
58 test_commit 9 &&
59 git branch right &&
60 git reset --hard 3 &&
61 test_merge M left right &&
62 git commit-graph write --reachable &&
63 graph_read_expect 10 "generation_data generation_data_overflow" &&
64 git commit-graph verify
65 )
Derrick Stoleec8d67b92022-03-01 19:48:32 +000066'
67
68graph_git_behavior 'overflow 2' repo left right
69
Patrick Steinhardtd3af1c12023-03-27 10:08:25 +020070test_expect_success 'single commit with generation data exceeding UINT32_MAX' '
71 git init repo-uint32-max &&
Taylor Blau749f1262023-07-24 12:39:31 -040072 test_commit -C repo-uint32-max --date "@4294967297 +0000" 1 &&
73 git -C repo-uint32-max commit-graph write --reachable &&
74 graph_read_expect -C repo-uint32-max 1 "generation_data" &&
75 git -C repo-uint32-max commit-graph verify
Patrick Steinhardtd3af1c12023-03-27 10:08:25 +020076'
77
Jeff Kingee6a7922023-10-09 17:05:47 -040078test_expect_success 'reader notices out-of-bounds generation overflow' '
79 graph=.git/objects/info/commit-graph &&
80 test_when_finished "rm -rf $graph" &&
81 git commit-graph write --reachable &&
82 corrupt_chunk_file $graph GDO2 clear &&
83 test_must_fail git log 2>err &&
84 grep "commit-graph overflow generation data is too small" err
85'
86
Derrick Stolee75979d92022-03-01 19:48:30 +000087test_done