Thread (2 messages) 2 messages, 2 authors, 2025-06-03

Re: [PATCH v2 1/4] midx: access pack names through `nth_midxed_pack_name()`

From: Taylor Blau <hidden>
Date: 2025-06-03 22:23:06

On Thu, May 29, 2025 at 01:51:03PM -0700, Junio C Hamano wrote:
Taylor Blau [off-list ref] writes:
quoted
Accessing a MIDX's 'pack_names' array is somewhat error-prone when
dealing with incremental MIDX chains, where the (global) pack_int_id for
some pack may differ from the containing layer's index for that pack.

Introduce `nth_midxed_pack_name()` in an effort to reduce a common
source of errors by discouraging external callers from accessing a
layer's `pack_names` array directly.

Signed-off-by: Taylor Blau <redacted>
---
 midx.c                    | 7 +++++++
 midx.h                    | 2 ++
 pack-bitmap.c             | 4 ++--
 t/helper/test-read-midx.c | 7 ++++---
 4 files changed, 15 insertions(+), 5 deletions(-)
One thing I forgot to ask.  Should we expect that

	$ git grep -E -e '(\.|->)pack_names\['

to give hits only from the implementation of nth_midxed_pack_name()?
I waffled on this a bit... and I think the answer is "almost". Certainly
callers outside of midx.c or midx-write.c should not be touching
"pack_names" directly.

But there are a couple of spots in midx-write.c that are really more
convenient to directly look at the pack_names array rather than going
through the accessor.

Thanks,
Taylor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help