mirror of
https://github.com/git/git.git
synced 2024-10-29 21:37:53 +01:00
t5319: make test work with SHA-256
This test corrupts various locations in a multi-pack index to test various error responses. However, these offsets differ between SHA-1 indexes and SHA-256 indexes due to differences in object length. Use test_oid to look up the correct offsets based on the algorithm. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
235d3cddb8
commit
3c5e65cac1
1 changed files with 18 additions and 4 deletions
|
@ -28,6 +28,20 @@ midx_read_expect () {
|
|||
test_cmp expect actual
|
||||
}
|
||||
|
||||
test_expect_success 'setup' '
|
||||
test_oid_init &&
|
||||
test_oid_cache <<-EOF
|
||||
idxoff sha1:2999
|
||||
idxoff sha256:3739
|
||||
|
||||
packnameoff sha1:652
|
||||
packnameoff sha256:940
|
||||
|
||||
fanoutoff sha1:1
|
||||
fanoutoff sha256:3
|
||||
EOF
|
||||
'
|
||||
|
||||
test_expect_success 'write midx with no packs' '
|
||||
test_when_finished rm -f pack/multi-pack-index &&
|
||||
git multi-pack-index --object-dir=. write &&
|
||||
|
@ -225,7 +239,7 @@ test_expect_success 'verify bad signature' '
|
|||
"multi-pack-index signature"
|
||||
'
|
||||
|
||||
HASH_LEN=20
|
||||
HASH_LEN=$(test_oid rawsz)
|
||||
NUM_OBJECTS=74
|
||||
MIDX_BYTE_VERSION=4
|
||||
MIDX_BYTE_OID_VERSION=5
|
||||
|
@ -238,9 +252,9 @@ MIDX_CHUNK_LOOKUP_WIDTH=12
|
|||
MIDX_OFFSET_PACKNAMES=$(($MIDX_HEADER_SIZE + \
|
||||
$MIDX_NUM_CHUNKS * $MIDX_CHUNK_LOOKUP_WIDTH))
|
||||
MIDX_BYTE_PACKNAME_ORDER=$(($MIDX_OFFSET_PACKNAMES + 2))
|
||||
MIDX_OFFSET_OID_FANOUT=$(($MIDX_OFFSET_PACKNAMES + 652))
|
||||
MIDX_OFFSET_OID_FANOUT=$(($MIDX_OFFSET_PACKNAMES + $(test_oid packnameoff)))
|
||||
MIDX_OID_FANOUT_WIDTH=4
|
||||
MIDX_BYTE_OID_FANOUT_ORDER=$((MIDX_OFFSET_OID_FANOUT + 250 * $MIDX_OID_FANOUT_WIDTH + 1))
|
||||
MIDX_BYTE_OID_FANOUT_ORDER=$((MIDX_OFFSET_OID_FANOUT + 250 * $MIDX_OID_FANOUT_WIDTH + $(test_oid fanoutoff)))
|
||||
MIDX_OFFSET_OID_LOOKUP=$(($MIDX_OFFSET_OID_FANOUT + 256 * $MIDX_OID_FANOUT_WIDTH))
|
||||
MIDX_BYTE_OID_LOOKUP=$(($MIDX_OFFSET_OID_LOOKUP + 16 * $HASH_LEN))
|
||||
MIDX_OFFSET_OBJECT_OFFSETS=$(($MIDX_OFFSET_OID_LOOKUP + $NUM_OBJECTS * $HASH_LEN))
|
||||
|
@ -387,7 +401,7 @@ test_expect_success 'force some 64-bit offsets with pack-objects' '
|
|||
pack64=$(git pack-objects --index-version=2,0x40 objects64/pack/test-64 <obj-list) &&
|
||||
idx64=objects64/pack/test-64-$pack64.idx &&
|
||||
chmod u+w $idx64 &&
|
||||
corrupt_data $idx64 2999 "\02" &&
|
||||
corrupt_data $idx64 $(test_oid idxoff) "\02" &&
|
||||
midx64=$(git multi-pack-index --object-dir=objects64 write) &&
|
||||
midx_read_expect 1 63 5 objects64 " large-offsets"
|
||||
'
|
||||
|
|
Loading…
Reference in a new issue