Skip to content
  • Jeff King's avatar
    midx: check both pack and index names for containment · 013fd7ad
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    A midx file (and the struct we parse from it) contains a list of all of
    the covered packfiles, mentioned by their ".idx" names (e.g.,
    "pack-1234.idx", etc). And thus calls to midx_contains_pack() expect
    callers to provide the idx name.
    
    This works for most of the calls, but the one in open_packed_git_1()
    tries to feed a packed_git->pack_name, which is the ".pack" name,
    meaning we'll never find a match (even if the pack is covered by the
    midx).
    
    We can fix this by converting the ".pack" to ".idx" in the caller.
    However, that requires allocating a new string. Instead, let's make
    midx_contains_pack() a bit friendlier, and allow it take _either_ the
    .pack or .idx variant.
    
    All cleverness in the matching code is credited to René. Bugs are mine.
    
    There's no test here, because while this does fix _a_ bug, it's masked
    by another bug in that same caller. That will be covered (with a test)
    in the next patch.
    
    Helped-by: default avatarRené Scharfe <l.s.r@web.de>
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    013fd7ad