Pia Park found that an incremental MIDX write can find new packs without finding new objects. The packs may be empty, or their objects may already be indexed by an earlier layer. The existing early exit checks only the number of packs, so a zero-object layer is published without a reverse index. The next incremental write with --bitmap then fails when it loads that reverse index.

The revised commit message traces the history. Empty MIDXs were already possible since 662148c435 (midx: write object offsets, 2018-07-12). The failure appeared with 27afc272c4 (midx: implement writing incremental MIDX bitmaps, 2025-03-20), when incremental bitmap writes began loading reverse indexes from prior layers. Park's reproduction starts from a bare repository with midx.version set to 2 and an empty pack.

Taylor Blau said the current version looks good to him and that the remaining questions can be handled outside this patch. Junio Hamano said he would queue it.