Skip to content

Commit 437787a

Browse files
derrickstoleegitster
authored andcommitted
commit-graph: test for corrupted octopus edge
The commit-graph file has an extra chunk to store the parent int-ids for parents beyond the first parent for octopus merges. Our test repo has a single octopus merge that we can manipulate to demonstrate the 'verify' subcommand detects incorrect values in that chunk. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 88968eb commit 437787a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

t/t5318-commit-graph.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ test_expect_success 'git commit-graph verify' '
248248
'
249249

250250
NUM_COMMITS=9
251+
NUM_OCTOPUS_EDGES=2
251252
HASH_LEN=20
252253
GRAPH_BYTE_VERSION=4
253254
GRAPH_BYTE_HASH=5
@@ -274,6 +275,10 @@ GRAPH_BYTE_COMMIT_EXTRA_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 4))
274275
GRAPH_BYTE_COMMIT_WRONG_PARENT=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 3))
275276
GRAPH_BYTE_COMMIT_GENERATION=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 11))
276277
GRAPH_BYTE_COMMIT_DATE=$(($GRAPH_COMMIT_DATA_OFFSET + $HASH_LEN + 12))
278+
GRAPH_COMMIT_DATA_WIDTH=$(($HASH_LEN + 16))
279+
GRAPH_OCTOPUS_DATA_OFFSET=$(($GRAPH_COMMIT_DATA_OFFSET + \
280+
$GRAPH_COMMIT_DATA_WIDTH * $NUM_COMMITS))
281+
GRAPH_BYTE_OCTOPUS=$(($GRAPH_OCTOPUS_DATA_OFFSET + 4))
277282

278283
# usage: corrupt_graph_and_verify <position> <data> <string>
279284
# Manipulates the commit-graph file at the position
@@ -383,4 +388,9 @@ test_expect_success 'detect incorrect commit date' '
383388
"commit date"
384389
'
385390

391+
test_expect_success 'detect incorrect parent for octopus merge' '
392+
corrupt_graph_and_verify $GRAPH_BYTE_OCTOPUS "\01" \
393+
"invalid parent"
394+
'
395+
386396
test_done

0 commit comments

Comments
 (0)