| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='commit graph with 64-bit timestamps' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | if ! test_have_prereq TIME_IS_64BIT || ! test_have_prereq TIME_T_IS_64BIT |
| 8 | then |
| 9 | skip_all='skipping 64-bit timestamp tests' |
| 10 | test_done |
| 11 | fi |
| 12 | |
| 13 | . "$TEST_DIRECTORY"/lib-commit-graph.sh |
| 14 | . "$TEST_DIRECTORY/lib-chunk.sh" |
| 15 | |
| 16 | UNIX_EPOCH_ZERO="@0 +0000" |
| 17 | FUTURE_DATE="@4147483646 +0000" |
| 18 | |
| 19 | GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=0 |
| 20 | |
| 21 | test_expect_success 'lower layers have overflow chunk' ' |
| 22 | rm -f .git/objects/info/commit-graph && |
| 23 | test_commit --date "$FUTURE_DATE" future-1 && |
| 24 | test_commit --date "$UNIX_EPOCH_ZERO" old-1 && |
| 25 | git commit-graph write --reachable && |
| 26 | test_commit --date "$FUTURE_DATE" future-2 && |
| 27 | test_commit --date "$UNIX_EPOCH_ZERO" old-2 && |
| 28 | git commit-graph write --reachable --split=no-merge && |
| 29 | test_commit extra && |
| 30 | git commit-graph write --reachable --split=no-merge && |
| 31 | git commit-graph write --reachable && |
| 32 | graph_read_expect 5 "generation_data generation_data_overflow" && |
| 33 | mv .git/objects/info/commit-graph commit-graph-upgraded && |
| 34 | git commit-graph write --reachable && |
| 35 | graph_read_expect 5 "generation_data generation_data_overflow" && |
| 36 | test_cmp .git/objects/info/commit-graph commit-graph-upgraded |
| 37 | ' |
| 38 | |
| 39 | graph_git_behavior 'overflow' '' HEAD~2 HEAD |
| 40 | |
| 41 | test_expect_success 'set up and verify repo with generation data overflow chunk' ' |
| 42 | git init repo && |
| 43 | ( |
| 44 | cd repo && |
| 45 | test_commit --date "$UNIX_EPOCH_ZERO" 1 && |
| 46 | test_commit 2 && |
| 47 | test_commit --date "$UNIX_EPOCH_ZERO" 3 && |
| 48 | git commit-graph write --reachable && |
| 49 | graph_read_expect 3 generation_data && |
| 50 | test_commit --date "$FUTURE_DATE" 4 && |
| 51 | test_commit 5 && |
| 52 | test_commit --date "$UNIX_EPOCH_ZERO" 6 && |
| 53 | git branch left && |
| 54 | git reset --hard 3 && |
| 55 | test_commit 7 && |
| 56 | test_commit --date "$FUTURE_DATE" 8 && |
| 57 | test_commit 9 && |
| 58 | git branch right && |
| 59 | git reset --hard 3 && |
| 60 | test_merge M left right && |
| 61 | git commit-graph write --reachable && |
| 62 | graph_read_expect 10 "generation_data generation_data_overflow" && |
| 63 | git commit-graph verify |
| 64 | ) |
| 65 | ' |
| 66 | |
| 67 | graph_git_behavior 'overflow 2' repo left right |
| 68 | |
| 69 | test_expect_success 'single commit with generation data exceeding UINT32_MAX' ' |
| 70 | git init repo-uint32-max && |
| 71 | test_commit -C repo-uint32-max --date "@4294967297 +0000" 1 && |
| 72 | git -C repo-uint32-max commit-graph write --reachable && |
| 73 | graph_read_expect -C repo-uint32-max 1 "generation_data" && |
| 74 | git -C repo-uint32-max commit-graph verify |
| 75 | ' |
| 76 | |
| 77 | test_expect_success 'descendant of commit with date exceeding UINT32_MAX' ' |
| 78 | git init repo-uint32-max-descendant && |
| 79 | test_commit -C repo-uint32-max-descendant \ |
| 80 | --date "@4294967300 +0000" future-parent && |
| 81 | test_commit -C repo-uint32-max-descendant present-day-child && |
| 82 | git -C repo-uint32-max-descendant commit-graph write --reachable && |
| 83 | git -C repo-uint32-max-descendant commit-graph verify |
| 84 | ' |
| 85 | |
| 86 | test_expect_success PERL_TEST_HELPERS 'reader notices out-of-bounds generation overflow' ' |
| 87 | graph=.git/objects/info/commit-graph && |
| 88 | test_when_finished "rm -rf $graph" && |
| 89 | git commit-graph write --reachable && |
| 90 | corrupt_chunk_file $graph GDO2 clear && |
| 91 | test_must_fail git log 2>err && |
| 92 | test_grep "commit-graph overflow generation data is too small" err |
| 93 | ' |
| 94 | |
| 95 | test_done |