On 12/21/2019 2:49 PM, brian m. carlson wrote: > 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. > --- > t/t5319-multi-pack-index.sh | 22 ++++++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > > diff --git a/t/t5319-multi-pack-index.sh b/t/t5319-multi-pack-index.sh > index 464bb68e89..43a7a66c9d 100755 > --- a/t/t5319-multi-pack-index.sh > +++ b/t/t5319-multi-pack-index.sh > @@ -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) I'm glad this was an easy update. > +MIDX_OFFSET_OID_FANOUT=$(($MIDX_OFFSET_PACKNAMES + $(test_oid packnameoff))) > +MIDX_BYTE_OID_FANOUT_ORDER=$((MIDX_OFFSET_OID_FANOUT + 250 * $MIDX_OID_FANOUT_WIDTH + $(test_oid fanoutoff))) I see why these are necessary: we need to find an exact position that causes an order check to fail. In that sense, the offsets need to match the early bytes of a packfile name or an OID fanout value. > @@ -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" && Sorry that this was not a better-calculated value, but your approach works well here. Thanks, -Stolee