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

Re: [RFC PATCH 04/10] repack: teach MIDX retention about geometric rollups

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 26, 2026, 21:28 UTC
Message-ID
<xmqqwlvl56vh.fsf@gitster.g>
In-Reply-To
<ad76f06fc7ed304af97c73a5931e1ebc5f2d3895.1782500507.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
Show 21 quoted lines
> +static int pack_geometry_contains_pack(struct packed_git **packs,
> +				       uint32_t packs_nr,
> +				       const char *base)
> +{
> +	struct strbuf buf = STRBUF_INIT;
> +	uint32_t i;
> +
> +	for (i = 0; i < packs_nr; i++) {
> +		strbuf_reset(&buf);
> +		strbuf_addstr(&buf, pack_basename(packs[i]));
> +		strbuf_strip_suffix(&buf, ".pack");
> +
> +		if (!strcmp(buf.buf, base)) {
> +			strbuf_release(&buf);
> +			return 1;
> +		}
> +	}
> +
> +	strbuf_release(&buf);
> +	return 0;
> +}

It feels slightly inefficient to repeatedly strbuf_reset(), strbuf_addstr(), and strbuf_strip_suffix() in the loop. I do not know if my understanding of what existing_packs_retain_midx_packs() passes down in buf.buf as base is correct or not, but if so, wouldn't it equivalent to

	for (uint32_t i = 0; i < packs_nr; i++) {
                const char *pack_name = pack_basename(packs[i]);
                const char *suffix;
                if (skip_prefix(pack_name, base, &suffix) &&
                    !strcmp(suffix, ".pack"))
                        return 1;
	}
perhaps?

Starting from "/path/to/objects/pack/pack-deadbeef.pack", you take the basename of it to have "pack-deadbeef.pack" in buf, strip out the ".pack" suffix to get "pack-deadbeef" in buf and then compare it with the base.

Instead, pack_name in the rewitten one becomes the basename of the packfile path, i.e., "pack-deadbeef.pack", then we see if it begins with base and take the remainder in suffix, and finally we check if that remaining suffix is ".pack".

Which should be equivalent.
Show 13 quoted lines
> + * freshly-written pack supersedes them. When doing a geometric repack,
> + * packs below the split are rewritten into the new MIDX tip and should
> + * remain eligible for deletion.
>   */
> -void existing_packs_retain_midx_packs(struct existing_packs *existing)
> +void existing_packs_retain_midx_packs(struct existing_packs *existing,
> +				      const struct pack_geometry *geometry)
>  {
>  	struct string_list_item *item;
>  	struct strbuf buf = STRBUF_INIT;
> @@ -315,6 +351,9 @@ void existing_packs_retain_midx_packs(struct existing_packs *existing)
>  		strbuf_strip_suffix(&buf, ".pack");
>  		strbuf_strip_suffix(&buf, ".idx");

Not a fault of this patch, but it makes the hairs on the back of my head tingle to see that a bogus input like "pack-foobar.idx.pack" happily is taken, while "pack-foobar.pack.idx", an equally bogus input, is not.

> +		if (pack_geometry_contains_rollup(geometry, buf.buf))
> +			continue;
Previous: Taylor BlauNext: Taylor Blau
Message 5 of 18 in “repack: combine '--geometric' and '--cruft'”
  1. 00/10 repack: combine '--geometric' and '--cruft'Taylor Blau, Jun 26, 2026
  2. 01/10 repack: unconditionally exclude non-kept packsTaylor Blau, Jun 26, 2026
  3. 03/10 repack: mark geometric progression of packs as retainedTaylor Blau, Jun 26, 2026
  4. 04/10 repack: teach MIDX retention about geometric rollupsTaylor Blau, Jun 26, 2026
  5. Junio C HamanoJun 26, 2026
  6. Taylor BlauJun 27, 2026
  7. 05/10 repack: delete geometric packs via existing_packsTaylor Blau, Jun 26, 2026
  8. 06/10 repack-geometry: drop unused redundant-pack removalTaylor Blau, Jun 26, 2026
  9. 02/10 repack: extract `locate_existing_pack()` helperTaylor Blau, Jun 26, 2026
  10. 07/10 pack-objects: extract `stdin_packs_add_all_pack_entries()`Taylor Blau, Jun 26, 2026
  11. 08/10 pack-objects: introduce '--stdin-packs=follow-reachable'Taylor Blau, Jun 26, 2026
  12. Junio C HamanoJun 26, 2026
  13. Taylor BlauJun 27, 2026
  14. Junio C HamanoJun 27, 2026
  15. Taylor BlauJun 27, 2026
  16. 09/10 pack-objects: support '--refs-snapshot' with 'follow-reachable'Taylor Blau, Jun 26, 2026
  17. 10/10 repack: support combining '--geometric' with '--cruft'Taylor Blau, Jun 26, 2026
  18. Junio C HamanoJul 27, 2026

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.