Skip to content

Commit 85fe23e

Browse files
Nicolas Pitregitster
authored andcommitted
verify-pack: test for detection of index v2 object CRC mismatch
Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c41a4a9 commit 85fe23e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

t/t5302-pack-index.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,18 @@ test_expect_success \
162162
'[index v2] 5) pack-objects refuses to reuse corrupted data' \
163163
'! git pack-objects test-5 <obj-list'
164164

165+
test_expect_success \
166+
'[index v2] 6) verify-pack detects CRC mismatch' \
167+
'rm -f .git/objects/pack/* &&
168+
git-index-pack --index-version=2 --stdin < "test-1-${pack1}.pack" &&
169+
git verify-pack ".git/objects/pack/pack-${pack1}.pack" &&
170+
chmod +w ".git/objects/pack/pack-${pack1}.idx" &&
171+
dd if=/dev/zero of=".git/objects/pack/pack-${pack1}.idx" conv=notrunc \
172+
bs=1 count=4 seek=$((8 + 256 * 4 + `wc -l <obj-list` * 20 + 0)) &&
173+
( while read obj
174+
do git cat-file -p $obj >/dev/null || exit 1
175+
done <obj-list ) &&
176+
err=$(! git verify-pack ".git/objects/pack/pack-${pack1}.pack" 2>&1) &&
177+
echo "$err" | grep "CRC mismatch"'
178+
165179
test_done

0 commit comments

Comments
 (0)