Derrick Stolee | 75979d9 | 2022-03-01 19:48:30 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='commit graph with 64-bit timestamps' |
Jeff King | d9c84c6 | 2023-10-03 16:31:11 -0400 | [diff] [blame] | 4 | |
| 5 | TEST_PASSES_SANITIZE_LEAK=true |
Derrick Stolee | 75979d9 | 2022-03-01 19:48:30 +0000 | [diff] [blame] | 6 | . ./test-lib.sh |
| 7 | |
| 8 | if ! test_have_prereq TIME_IS_64BIT || ! test_have_prereq TIME_T_IS_64BIT |
| 9 | then |
| 10 | skip_all='skipping 64-bit timestamp tests' |
| 11 | test_done |
| 12 | fi |
| 13 | |
| 14 | . "$TEST_DIRECTORY"/lib-commit-graph.sh |
Jeff King | ee6a792 | 2023-10-09 17:05:47 -0400 | [diff] [blame] | 15 | . "$TEST_DIRECTORY/lib-chunk.sh" |
Derrick Stolee | 75979d9 | 2022-03-01 19:48:30 +0000 | [diff] [blame] | 16 | |
| 17 | UNIX_EPOCH_ZERO="@0 +0000" |
| 18 | FUTURE_DATE="@4147483646 +0000" |
| 19 | |
| 20 | GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0 |
| 21 | |
| 22 | test_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 | |
| 40 | graph_git_behavior 'overflow' '' HEAD~2 HEAD |
| 41 | |
Derrick Stolee | c8d67b9 | 2022-03-01 19:48:32 +0000 | [diff] [blame] | 42 | test_expect_success 'set up and verify repo with generation data overflow chunk' ' |
Taylor Blau | 749f126 | 2023-07-24 12:39:31 -0400 | [diff] [blame] | 43 | 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 Stolee | c8d67b9 | 2022-03-01 19:48:32 +0000 | [diff] [blame] | 66 | ' |
| 67 | |
| 68 | graph_git_behavior 'overflow 2' repo left right |
| 69 | |
Patrick Steinhardt | d3af1c1 | 2023-03-27 10:08:25 +0200 | [diff] [blame] | 70 | test_expect_success 'single commit with generation data exceeding UINT32_MAX' ' |
| 71 | git init repo-uint32-max && |
Taylor Blau | 749f126 | 2023-07-24 12:39:31 -0400 | [diff] [blame] | 72 | 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 Steinhardt | d3af1c1 | 2023-03-27 10:08:25 +0200 | [diff] [blame] | 76 | ' |
| 77 | |
Jeff King | ee6a792 | 2023-10-09 17:05:47 -0400 | [diff] [blame] | 78 | test_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 Stolee | 75979d9 | 2022-03-01 19:48:30 +0000 | [diff] [blame] | 87 | test_done |