Re: [PATCH 09/11] pack-bitmap: handle missing bitmap for base MIDX
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 10, 2026, 03:41 UTC
- Message-ID
- <xmqqv7anfr5b.fsf@gitster.g>
- In-Reply-To
- <0b27860478a284719755b8ac2386862c1fc3d0e7.1783590159.git.gitgitgadget@gmail.com>
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 9 quoted lines
> This can happen in practice with incremental MIDX chains: the base MIDX > may have been written without `--write-bitmap-index`, or the bitmap may > have been pruned while the incremental layer's bitmap still references > it. > > Check the return value and go to the cleanup label (which unmaps the > current bitmap and returns -1) so the caller falls back to non-bitmap > object enumeration, matching the handling of other bitmap loading > failures in the same function.
Nicely reasoned. It would have been nicer to CC those who are more familiar with the area, though.
Cc'ed Taylor for incremental MIDX expertise just in case.
Thanks.
Show 24 quoted lines
>
> Pointed out by Coverity.
>
> Assisted-by: Claude Opus 4.6
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> pack-bitmap.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/pack-bitmap.c b/pack-bitmap.c
> index e8a82945cc..ca7998c10b 100644
> --- a/pack-bitmap.c
> +++ b/pack-bitmap.c
> @@ -523,6 +523,10 @@ static int open_midx_bitmap_1(struct bitmap_index *bitmap_git,
>
> if (midx->base_midx) {
> bitmap_git->base = prepare_midx_bitmap_git(midx->base_midx);
> + if (!bitmap_git->base) {
> + warning(_("could not open bitmap for base MIDX"));
> + goto cleanup;
> + }
> bitmap_git->base_nr = bitmap_git->base->base_nr + 1;
> } else {
> bitmap_git->base_nr = 0;