git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH 1/2] midx: fix `BUG()` when getting preferred pack without a reverse index
Date: Thu, 18 Dec 2025 16:13:32 -0500	[thread overview]
Message-ID: <aURufIXsiNfPh02X@nand.local> (raw)
In-Reply-To: <aTk_-pvNA31ScZyu@pks.im>

On Wed, Dec 10, 2025 at 10:40:10AM +0100, Patrick Steinhardt wrote:
> 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

  reply	other threads:[~2025-12-18 21:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-08 18:27 [PATCH 0/2] builtin/repack: avoid rewriting up-to-date MIDX Patrick Steinhardt
2025-12-08 18:27 ` [PATCH 1/2] midx: fix `BUG()` when getting preferred pack without a reverse index Patrick Steinhardt
2025-12-10  0:22   ` Taylor Blau
2025-12-10  9:40     ` Patrick Steinhardt
2025-12-18 21:13       ` Taylor Blau [this message]
2025-12-08 18:27 ` [PATCH 2/2] builtin/repack: don't regenerate MIDX unless needed Patrick Steinhardt
2025-12-10  2:48   ` Taylor Blau
2025-12-10  9:40     ` Patrick Steinhardt
2025-12-10 12:52 ` [PATCH v2 0/3] builtin/repack: avoid rewriting up-to-date MIDX Patrick Steinhardt
2025-12-10 12:52   ` [PATCH v2 1/3] midx: fix `BUG()` when getting preferred pack without a reverse index Patrick Steinhardt
2025-12-10 12:52   ` [PATCH v2 2/3] midx-write: extract function to test whether MIDX needs updating Patrick Steinhardt
2025-12-10 12:52   ` [PATCH v2 3/3] midx-write: skip rewriting MIDX with `--stdin-packs` unless needed Patrick Steinhardt
2025-12-11  8:46   ` [PATCH v2 0/3] builtin/repack: avoid rewriting up-to-date MIDX Junio C Hamano
2025-12-12  7:33     ` Patrick Steinhardt
2025-12-18 21:18       ` Taylor Blau
2025-12-19  6:25         ` Patrick Steinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aURufIXsiNfPh02X@nand.local \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).