multi-pack-index: verify oid lookup order
Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2f23d3f3f9
commit
55c5648d80
11
midx.c
11
midx.c
@ -959,5 +959,16 @@ int verify_midx_file(const char *object_dir)
|
||||
i, oid_fanout1, oid_fanout2, i + 1);
|
||||
}
|
||||
|
||||
for (i = 0; i < m->num_objects - 1; i++) {
|
||||
struct object_id oid1, oid2;
|
||||
|
||||
nth_midxed_object_oid(&oid1, m, i);
|
||||
nth_midxed_object_oid(&oid2, m, i + 1);
|
||||
|
||||
if (oidcmp(&oid1, &oid2) >= 0)
|
||||
midx_report(_("oid lookup out of order: oid[%d] = %s >= %s = oid[%d]"),
|
||||
i, oid_to_hex(&oid1), oid_to_hex(&oid2), i + 1);
|
||||
}
|
||||
|
||||
return verify_midx_error;
|
||||
}
|
||||
|
@ -175,6 +175,7 @@ test_expect_success 'verify bad signature' '
|
||||
"multi-pack-index signature"
|
||||
'
|
||||
|
||||
HASH_LEN=20
|
||||
MIDX_BYTE_VERSION=4
|
||||
MIDX_BYTE_OID_VERSION=5
|
||||
MIDX_BYTE_CHUNK_COUNT=6
|
||||
@ -189,6 +190,8 @@ MIDX_BYTE_PACKNAME_ORDER=$(($MIDX_OFFSET_PACKNAMES + 2))
|
||||
MIDX_OFFSET_OID_FANOUT=$(($MIDX_OFFSET_PACKNAMES + 652))
|
||||
MIDX_OID_FANOUT_WIDTH=4
|
||||
MIDX_BYTE_OID_FANOUT_ORDER=$((MIDX_OFFSET_OID_FANOUT + 250 * $MIDX_OID_FANOUT_WIDTH + 1))
|
||||
MIDX_OFFSET_OID_LOOKUP=$(($MIDX_OFFSET_OID_FANOUT + 256 * $MIDX_OID_FANOUT_WIDTH))
|
||||
MIDX_BYTE_OID_LOOKUP=$(($MIDX_OFFSET_OID_LOOKUP + 16 * $HASH_LEN))
|
||||
|
||||
test_expect_success 'verify bad version' '
|
||||
corrupt_midx_and_verify $MIDX_BYTE_VERSION "\00" $objdir \
|
||||
@ -235,6 +238,11 @@ test_expect_success 'verify oid fanout out of order' '
|
||||
"oid fanout out of order"
|
||||
'
|
||||
|
||||
test_expect_success 'verify oid lookup out of order' '
|
||||
corrupt_midx_and_verify $MIDX_BYTE_OID_LOOKUP "\00" $objdir \
|
||||
"oid lookup out of order"
|
||||
'
|
||||
|
||||
test_expect_success 'repack removes multi-pack-index' '
|
||||
test_path_is_file $objdir/pack/multi-pack-index &&
|
||||
git repack -adf &&
|
||||
|
Loading…
Reference in New Issue
Block a user