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

Re: [PATCH 1/2] midx: fix `BUG()` when getting preferred pack without a reverse index

From
Taylor Blau <me@ttaylorr.com>
Date
Dec 18, 2025, 21:13 UTC
Message-ID
<aURufIXsiNfPh02X@nand.local>
In-Reply-To
<aTk_-pvNA31ScZyu@pks.im>
On Wed, Dec 10, 2025 at 10:40:10AM +0100, Patrick Steinhardt wrote:
Show 34 quoted lines
> On Tue, Dec 09, 2025 at 07:22:11PM -0500, Taylor Blau wrote:
> > On Mon, Dec 08, 2025 at 07:27:14PM +0100, Patrick Steinhardt wrote:
> > > 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.
> > >
> > >   2. Convert this position from pseudo-pack order into MIDX order.
> > >
> > >   3. We then look up pack that corresponds to this MIDX index.
> >
> > I think the implementation of midx_preferred_pack() works a little bit
> > differently than is described here. I often get confused when working in
> > this area juggling between the various object/pack orderings in my head.
>
> Hm, I feel like I am missing something.
>
> > midx_preferred_pack() cares about converting from the first position in
> > pseudo-pack order back into MIDX object order. To do that, we convert
> > the pseudo-pack position into a MIDX one, and then lookup the pack that
> > represents that object.
>
> Isn't that what I say in (2) and (3)? Or is this about (1) being
> inaccurate? Would this sequence be more accurate:
>
>   1. Take the first position indexed by the MIDX in pseudo-pack order.
>
>   2. Convert this pseudo-pack position into the MIDX position.
>
>   3. We then look up the pack that corresponds to this MIDX position.
>
> In any case, I agree with you that juggling these different positions is
> quite something :)

I was thinking about (1) being inaccurate, but the rephrasing you provided here and in the new version of the patch look good to me.

Both (2) and (3) from your original patch are correct. I was commenting here on the phrasing in (1) suggesting we "look up" a position from the MIDX, which is inaccurate. The position is given as the first position in pseudo-pack order, and "take the first position" perfectly captures that.

Thanks, Taylor

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 5 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.