From: Junio C Hamano Date: Thu, 30 Jul 2026 17:44:41 +0000 (-0700) Subject: Merge branch 'tb/pack-with-duplicates' into seen X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=509a490b11918a939564ba05eea700888c8e1916;p=thirdparty%2Fgit.git Merge branch 'tb/pack-with-duplicates' into seen The handling of packfiles with duplicate object entries has been hardened. Specifically, reverse index lookup, delta cycle recovery, multi-pack-index verification, and pack reuse paths have been updated to correctly handle or gracefully reject duplicate entries. * tb/pack-with-duplicates: pack-bitmap: handle duplicate pack entries during MIDX reuse test-tool bitmap: reject packs with duplicate objects midx: verify duplicate pack entries by OID and offset packfile: recover delta cycles through duplicate entries t5308: test reverse indexes with duplicate objects --- 509a490b11918a939564ba05eea700888c8e1916 diff --cc pack-bitmap.c index d797614e34,8141290436..6ebd974fce --- a/pack-bitmap.c +++ b/pack-bitmap.c @@@ -2388,7 -2383,8 +2388,8 @@@ static void reuse_partial_packfile_from struct pack_window *w_curs = NULL; size_t pos = pack->bitmap_pos / BITS_IN_EWORD; - if (allow_ref_delta && !pack->bitmap_pos) { - if (!pack->bitmap_pos && ++ if (allow_ref_delta && !pack->bitmap_pos && + pack->bitmap_nr == pack->p->num_objects) { /* * If we're processing the first (in the case of a MIDX, the * preferred pack) or the only (in the case of single-pack @@@ -2403,9 -2401,8 +2404,12 @@@ * we're currently processing). So any duplicate bases will be * resolved in favor of the pack we're processing. * + * When REF_DELTAs are allowed, we can therefore reuse whole + * words at a time without inspecting object headers. Otherwise, + * inspect each object below to avoid reusing a REF_DELTA entry. ++ * + * The range must also contain every physical pack entry so that + * bitmap and pack positions correspond. */ while (pos < result->word_alloc && pos < pack->bitmap_nr / BITS_IN_EWORD &&