git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/3] builtin/repack: avoid rewriting up-to-date MIDX

From
Patrick Steinhardt <ps@pks.im>
Date
Dec 10, 2025, 12:52 UTC
Message-ID
<20251210-pks-skip-noop-rewrite-v2-0-f813a9e44f28@pks.im>
In-Reply-To
<20251208-pks-skip-noop-rewrite-v1-0-430d52dba9f0@pks.im>
Hi,

this small patch series introduces logic to avoid rewriting the multi-pack index in case it's up-to-date already. This is especially relevant in the context of geometric repacking, where we may decide to not write any new packfiles, but we'd still rewrite the multi-pack index.

This is a follow-up for the discussion that happened at [1].
Changes in v2:
  - Move the logic to skip writing updates into `write_midx_internal()`.
    We already had some logic there to skip no-op rewrites, so we only
    extend that logic now to handle the "--stdin-packs" option. This
    also has the added benefit that we know to strip bitmaps in case the
    write is a no-op.
  - I don't handle the case anymore where the preferred pack is
    changing. We didn't do so in the preexisting checks either, so I
    decided to drop this for now. This _can_ be considered as a bug, and
    if anyone thinks it is then I'll extend these checks.
  - Adapt the tests to use git-multi-pack-index(1) directly.
  - Link to v1: https://lore.kernel.org/r/20251208-pks-skip-noop-rewrite-v1-0-430d52dba9f0@pks.im
Thanks!
Patrick
[1]: <20251025191550.GA279793@coredump.intra.peff.net>
---
Patrick Steinhardt (3):
      midx: fix `BUG()` when getting preferred pack without a reverse index
      midx-write: extract function to test whether MIDX needs updating
      midx-write: skip rewriting MIDX with `--stdin-packs` unless needed
 midx-write.c                | 113 ++++++++++++++++++++++++++++++++++++--------
 midx.c                      |   2 +-
 pack-revindex.h             |   3 +-
 t/t5319-multi-pack-index.sh |  64 +++++++++++++++++++++++++
 t/t7703-repack-geometric.sh |  35 ++++++++++++++
 5 files changed, 195 insertions(+), 22 deletions(-)
Range-diff versus v1:
1:  11258a799b ! 1:  88ba93d3a5 midx: fix `BUG()` when getting preferred pack without a reverse index
    @@ Commit message
         The function `midx_preferred_pack()` returns the preferred pack for a
         given multi-pack index. To compute the preferred pack we:
     
    -      1. Look up the position of the first object indexed by the multi-pack
    -         index.
    +      1. Take the first position indexed by the MIDX in pseudo-pack order.
     
    -      2. Convert this position from pseudo-pack order into MIDX order.
    +      2. Convert this pseudo-pack position into the MIDX position.
     
    -      3. We then look up pack that corresponds to this MIDX index.
    +      3. We then look up the pack that corresponds to this MIDX position.
     
         This reliably returns the preferred pack given that all of its contained
         objects will be up front in pseudo-pack order.
2:  baf307b521 < -:  ---------- builtin/repack: don't regenerate MIDX unless needed
-:  ---------- > 2:  9bd320b2cf midx-write: extract function to test whether MIDX needs updating
-:  ---------- > 3:  f594865c12 midx-write: skip rewriting MIDX with `--stdin-packs` unless needed

--- base-commit: bdc5341ff65278a3cc80b2e8a02a2f02aa1fac06 change-id: 20251208-pks-skip-noop-rewrite-38d7f01c79c5

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 9 of 16 in “builtin/repack: avoid rewriting up-to-date MIDX”
  1. 0/2 builtin/repack: avoid rewriting up-to-date MIDXPatrick Steinhardt, Dec 8, 2025
  2. 1/2 midx: fix `BUG()` when getting preferred pack without a reverse indexPatrick Steinhardt, Dec 8, 2025
  3. Taylor BlauDec 10, 2025
  4. Patrick SteinhardtDec 10, 2025
  5. Taylor BlauDec 18, 2025
  6. 2/2 builtin/repack: don't regenerate MIDX unless neededPatrick Steinhardt, Dec 8, 2025
  7. Taylor BlauDec 10, 2025
  8. Patrick SteinhardtDec 10, 2025
  9. 0/3 builtin/repack: avoid rewriting up-to-date MIDXPatrick Steinhardt, Dec 10, 2025
  10. 1/3 midx: fix `BUG()` when getting preferred pack without a reverse indexPatrick Steinhardt, Dec 10, 2025
  11. 2/3 midx-write: extract function to test whether MIDX needs updatingPatrick Steinhardt, Dec 10, 2025
  12. 3/3 midx-write: skip rewriting MIDX with `--stdin-packs` unless neededPatrick Steinhardt, Dec 10, 2025
  13. Junio C HamanoDec 11, 2025
  14. Patrick SteinhardtDec 12, 2025
  15. Taylor BlauDec 18, 2025
  16. Patrick SteinhardtDec 19, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.