[This brief series is based on ps/midx-negative-packfile-cache]. This series implements a suggestion from this thread to have prepare_midx_pack() return a pointer to packed_git structure identified by the given pack_int_id. This convention makes converting a pack_int_id into a bona-fide pack significantly less error-prone, particularly when dealing with incremental MIDXs. Along the way, I noticed a couple of opportunities for clean-up and light refactorings, which make up the first four patches. In the future, I think we could take this further by: - applying the same pattern to the 'pack_names' array, and - renaming both arrays something like 'packs_' or similar to indicate that they are "private" and should not be accessed outside of midx.c. We might be able to go even further than that by making the entire structure opaque to external callers by defining it within midx.c itself. We don't get there in this series, but it sets us on the right direction. Thanks in advance for your review! Taylor Blau (5): pack-bitmap.c: fix broken warning() when missing MIDX'd pack midx-write.c: guard against incremental MIDXs in want_included_pack() midx-write.c: simplify fill_packs_from_midx() midx-write.c: extract inner loop from fill_packs_from_midx() midx: return a `packed_git` pointer from `prepare_midx_pack()` midx-write.c | 114 +++++++++++++++++++++++++++++++------------------- midx.c | 81 ++++++++++++++++++----------------- midx.h | 4 +- pack-bitmap.c | 4 +- 4 files changed, 115 insertions(+), 88 deletions(-) base-commit: 73fe0882eec06f7b9ea021fe062a32cd1731e574 -- 2.49.0.641.gb9c9c4c3bd