Skip to content

Commit 693900b

Browse files
committed
commit-graph: test verifying a corrupt v2 header
The commit-graph file format v2 changes the v1 data only in the header information. Add tests that check the 'verify' subcommand catches corruption in the v2 header. Signed-off-by: Derrick Stolee <[email protected]>
1 parent c55e0a7 commit 693900b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

t/t5318-commit-graph.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,37 @@ test_expect_success 'git fsck (checks commit-graph)' '
497497
test_must_fail git fsck
498498
'
499499

500+
test_expect_success 'rewrite commmit-graph with version 2' '
501+
rm -f .git/objects/info/commit-graph &&
502+
git commit-graph write --reachable --version=2 &&
503+
git commit-graph verify
504+
'
505+
506+
GRAPH_BYTE_CHUNK_COUNT=5
507+
GRAPH_BYTE_REACH_INDEX=6
508+
GRAPH_BYTE_UNUSED=7
509+
GRAPH_BYTE_HASH=8
510+
511+
test_expect_success 'detect low chunk count (v2)' '
512+
corrupt_graph_and_verify $GRAPH_CHUNK_COUNT "\02" \
513+
"missing the .* chunk"
514+
'
515+
516+
test_expect_success 'detect incorrect reachability index' '
517+
corrupt_graph_and_verify $GRAPH_REACH_INDEX "\03" \
518+
"reachability index version"
519+
'
520+
521+
test_expect_success 'detect non-zero unused byte' '
522+
corrupt_graph_and_verify $GRAPH_BYTE_UNUSED "\01" \
523+
"unsupported value"
524+
'
525+
526+
test_expect_success 'detect bad hash version (v2)' '
527+
corrupt_graph_and_verify $GRAPH_BYTE_HASH "\00" \
528+
"hash algorithm"
529+
'
530+
500531
test_expect_success 'setup non-the_repository tests' '
501532
rm -rf repo &&
502533
git init repo &&

0 commit comments

Comments
 (0)