Skip to content

Commit

Permalink
commit-graph: test verifying a corrupt v2 header
Browse files Browse the repository at this point in the history
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 <dstolee@microsoft.com>
  • Loading branch information
derrickstolee committed Jan 23, 2019
1 parent c55e0a7 commit 693900b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions t/t5318-commit-graph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,37 @@ test_expect_success 'git fsck (checks commit-graph)' '
test_must_fail git fsck
'

test_expect_success 'rewrite commmit-graph with version 2' '
rm -f .git/objects/info/commit-graph &&
git commit-graph write --reachable --version=2 &&
git commit-graph verify
'

GRAPH_BYTE_CHUNK_COUNT=5
GRAPH_BYTE_REACH_INDEX=6
GRAPH_BYTE_UNUSED=7
GRAPH_BYTE_HASH=8

test_expect_success 'detect low chunk count (v2)' '
corrupt_graph_and_verify $GRAPH_CHUNK_COUNT "\02" \
"missing the .* chunk"
'

test_expect_success 'detect incorrect reachability index' '
corrupt_graph_and_verify $GRAPH_REACH_INDEX "\03" \
"reachability index version"
'

test_expect_success 'detect non-zero unused byte' '
corrupt_graph_and_verify $GRAPH_BYTE_UNUSED "\01" \
"unsupported value"
'

test_expect_success 'detect bad hash version (v2)' '
corrupt_graph_and_verify $GRAPH_BYTE_HASH "\00" \
"hash algorithm"
'

test_expect_success 'setup non-the_repository tests' '
rm -rf repo &&
git init repo &&
Expand Down

0 comments on commit 693900b

Please sign in to comment.