index-pack --verify: read anomalous offsets from v2 idx file

A pack v2 .idx file usually records offset using 64-bit representation
only when the offset does not fit within 31-bit, but you can handcraft
your .idx file to record smaller offset using 64-bit, storing all zero
in the upper 4-byte.  By inspecting the original idx file when running
index-pack --verify, encode such low offsets that do not need to be in
64-bit but are encoded using 64-bit just like the original idx file so
that we can still validate the pack/idx pair by comparing the idx file
recomputed with the original.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2011-02-25 16:55:26 -08:00
parent fb956c1f44
commit 3c9fc074c2
4 changed files with 74 additions and 2 deletions

View File

@ -107,7 +107,7 @@ test_expect_success OFF64_T 'index-pack --verify on 64-bit offset v2 (cheat)' '
git index-pack --verify --index-version=2,0x40000 "test-3-${pack3}.pack"
'
test_expect_failure OFF64_T 'index-pack --verify on 64-bit offset v2' '
test_expect_success OFF64_T 'index-pack --verify on 64-bit offset v2' '
git index-pack --verify "test-3-${pack3}.pack"
'