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>
Nicolas Pitre committed
Jun 24, 2008 at 23:19 UTC
85fe23ed2a5d88463f5362a3e4fdd6f45a0555fd
1 file changed
+14
t/t5302-pack-index.sh
+14
@@ -162,4 +162,18 @@ test_expect_success \
162
'[index v2] 5) pack-objects refuses to reuse corrupted data' \
163
'! git pack-objects test-5 <obj-list'
164
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
+
179
test_done