Re: [PATCH v2 1/4] midx: access pack names through `nth_midxed_pack_name()`
Taylor Blau <me@ttaylorr.com> writes:
Show 15 quoted lines
> 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 <me@ttaylorr.com>
> ---
> 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()?
Show 6 quoted lines
> +const char *nth_midxed_pack_name(struct multi_pack_index *m,
> + uint32_t pack_int_id)
> +{
> + uint32_t local_pack_int_id = midx_for_pack(&m, pack_int_id);
> + return m->pack_names[local_pack_int_id];
> +}