mirror of
https://github.com/git/git.git
synced 2026-08-09 01:21:47 +00:00
A MIDX retains one entry per OID, while a non-strict pack index can contain the same OID at several offsets. verify_midx_file() compares the recorded offset with find_pack_entry_one(), which may return a different member of that duplicate run and falsely report a valid MIDX as corrupt. Check instead that the exact OID/offset pair exists anywhere in the contiguous duplicate run in the source pack. That is the relevant invariant: same-pack duplicates have no canonical representation, and every matching physical copy is valid, including those recorded by existing MIDXs. This matches reader behavior. The OOFF chunk records the selected (pack, offset), and midx_to_pack_pos() reconstructs its RIDX position from that pair. If midx_pair_to_pack_pos() is given an unselected duplicate offset, the lookup misses and its sole caller falls back from partial reuse to normal packing. Readers therefore remain consistent with whichever representation the MIDX records. Write a MIDX over the existing duplicate-pack fixture, assert that its selected offset differs from find_pack_entry_one(), and verify it. Then run fsck as an application-level check. Signed-off-by: Taylor Blau <ttaylorr@openai.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
29 KiB
29 KiB