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

Re: [PATCH 1/1] midx: prevent writing a .bitmap without any objects

From
Derrick Stolee <stolee@gmail.com>
Date
Feb 10, 2022, 14:41 UTC
Message-ID
<748a2358-7bdf-5b28-09f9-5c4b266a3b52@gmail.com>
In-Reply-To
<abc67d757cb6b244cf54b7b030985180ce134724.1644434802.git.me@ttaylorr.com>
On 2/9/2022 2:26 PM, Taylor Blau wrote:
> When trying to write a MIDX, we already prevent the case where there
> weren't any packs present, and thus we would have written an empty MIDX.
Show 24 quoted lines
> diff --git a/midx.c b/midx.c
> index 6e6cb0eb04..865170bad0 100644
> --- a/midx.c
> +++ b/midx.c
> @@ -1077,6 +1077,9 @@ static int write_midx_bitmap(char *midx_name, unsigned char *midx_hash,
>  	char *bitmap_name = xstrfmt("%s-%s.bitmap", midx_name, hash_to_hex(midx_hash));
>  	int ret;
>  
> +	if (!ctx->entries_nr)
> +		BUG("cannot write a bitmap without any objects");
> +
>  	if (flags & MIDX_WRITE_BITMAP_HASH_CACHE)
>  		options |= BITMAP_OPT_HASH_CACHE;
>  
> @@ -1401,6 +1404,12 @@ static int write_midx_internal(const char *object_dir,
>  		goto cleanup;
>  	}
>  
> +	if (!ctx.entries_nr) {
> +		if (flags & MIDX_WRITE_BITMAP)
> +			warning(_("refusing to write multi-pack .bitmap without any objects"));
> +		flags &= ~(MIDX_WRITE_REV_INDEX | MIDX_WRITE_BITMAP);
> +	}
> +

This patch looks good to me. The code change is simple and the test is clear.

Thanks, -Stolee

Previous: Taylor Blau
Message 3 of 3 in “midx: prevent writing a bitmap with zero objects”
  1. 0/1 midx: prevent writing a bitmap with zero objectsTaylor Blau, Feb 9, 2022
  2. 1/1 midx: prevent writing a .bitmap without any objectsTaylor Blau, Feb 9, 2022
  3. Derrick StoleeFeb 10, 2022

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.