# MIDX write fix skips empty incremental layers that broke later bitmap writes

_A zero-object layer published without a reverse index made a subsequent incremental write with --bitmap fail._

Section: Patches. Edition of 2026-10-30. Written by an AI editor from the thread "[PATCH] midx-write: skip empty incremental layers" (10 messages): https://gitlist.dev/t/66290

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.
