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

Re: [PATCH v2 2/5] pack-objects: refactor `read_packs_list_from_stdin()` to use `strmap`

From
Taylor Blau <me@ttaylorr.com>
Date
Mar 26, 2026, 21:44 UTC
Message-ID
<acWoqXUwVUB2/65T@nand.local>
In-Reply-To
<9e320604-7367-4f48-a943-f7d22feb2672@gmail.com>
On Thu, Mar 26, 2026 at 04:40:00PM -0400, Derrick Stolee wrote:
Show 13 quoted lines
> On 3/25/2026 7:51 PM, Taylor Blau wrote:
>
> > -static void read_packs_list_from_stdin(struct rev_info *revs)
> > +struct stdin_pack_info {
> > +	struct packed_git *p;
> > +	enum {
> > +		STDIN_PACK_INCLUDE = (1<<0),
> > +		STDIN_PACK_EXCLUDE_CLOSED = (1<<1),
> > +	} kind;
> > +};
>
> I kind of wish this enum wasn't anonymous. And it matters later.
> Let's call this 'enum pack_input_kind' for now.

Hmm. I don't feel strongly about this, but I'm not sure I follow the reasoning here. The enum is truly only meant to be used within the context of a stdin_pack_info struct, so it felt natural to keep it anonymous above.

I'm happy to change this if you feel strongly about it, but TBH I am not sure I see the benefit of doing so.

Show 22 quoted lines
> It took me a while to figure out what was going on with checking
> *key == '^' and later checking *buf.buf == '^'. We should probably
> combine them to the same condition:
>
> 	const char *key = buf.buf;
> 	enum pack_input_kind kind = STDIN_PACK_INCLUDE;
>
> 	if (*key == '^') {
> 		key++;
> 		kind |= STDIN_PACK_EXCLUDE_CLOSED;
> 	}
>
> 	info = strmap_get(&packs, key);
> 	if (!info) {
> 		CALLOC_ARRAY(info, 1);
> 		strmap_put(&packs, key, info);
> 		info->kind = kind;
> 	}
>
> 	strbuf_reset(&buf);
>
> This feels easier to read, for me.

I agree that the above is a little easier to read, but I'm not sure it handles the case of specifying the same pack multiple times. I had originally written it in a similar way as what you suggested above, but it breaks if I write something like:

    cat <<EOF | git pack-objects --stdin
    pack-XYZ.pack
    ^pack-XYZ.pack
    EOF

It should produce a pack with no objects, but I think the code above would effectively ignore the second line because we already have a strmap entry for pack-XYZ.pack so we never set the additional flag bits.

Thanks, Taylor

Previous: Derrick StoleeNext: Junio C Hamano
Message 18 of 41 in “pack-objects: handle excluded-but-open packs via `--stdin-packs=follow`”
  1. 0/5 pack-objects: handle excluded-but-open packs via `--stdin-packs=follow`Taylor Blau, Mar 19, 2026
  2. 1/5 pack-objects: plug leak in `read_stdin_packs()`Taylor Blau, Mar 19, 2026
  3. Patrick SteinhardtMar 24, 2026
  4. Taylor BlauMar 25, 2026
  5. 2/5 pack-objects: refactor `read_packs_list_from_stdin()` to use `strmap`Taylor Blau, Mar 19, 2026
  6. Patrick SteinhardtMar 24, 2026
  7. Taylor BlauMar 25, 2026
  8. 3/5 t7704: demonstrate failure with once-cruft objects above the geometric splitTaylor Blau, Mar 19, 2026
  9. 4/5 pack-objects: support excluded-open packs with --stdin-packsTaylor Blau, Mar 19, 2026
  10. Jeff KingMar 21, 2026
  11. Taylor BlauMar 22, 2026
  12. Taylor BlauMar 25, 2026
  13. 5/5 repack: mark non-MIDX packs above the split as excluded-openTaylor Blau, Mar 19, 2026
  14. 0/5 pack-objects: handle excluded-but-open packs via `--stdin-packs=follow`Taylor Blau, Mar 25, 2026
  15. 1/5 pack-objects: plug leak in `read_stdin_packs()`Taylor Blau, Mar 25, 2026
  16. 2/5 pack-objects: refactor `read_packs_list_from_stdin()` to use `strmap`Taylor Blau, Mar 25, 2026
  17. Derrick StoleeMar 26, 2026
  18. Taylor BlauMar 26, 2026
  19. Junio C HamanoMar 26, 2026
  20. Taylor BlauMar 26, 2026
  21. Derrick StoleeMar 27, 2026
  22. Taylor BlauMar 27, 2026
  23. Derrick StoleeMar 27, 2026
  24. Junio C HamanoMar 27, 2026
  25. Taylor BlauMar 26, 2026
  26. 3/5 t7704: demonstrate failure with once-cruft objects above the geometric splitTaylor Blau, Mar 25, 2026
  27. 4/5 pack-objects: support excluded-open packs with --stdin-packsTaylor Blau, Mar 25, 2026
  28. Derrick StoleeMar 26, 2026
  29. 5/5 repack: mark non-MIDX packs above the split as excluded-openTaylor Blau, Mar 25, 2026
  30. Derrick StoleeMar 26, 2026
  31. Taylor BlauMar 26, 2026
  32. Derrick StoleeMar 26, 2026
  33. Taylor BlauMar 26, 2026
  34. 0/5 pack-objects: handle excluded-but-open packs via `--stdin-packs=follow`Taylor Blau, Mar 27, 2026
  35. 1/5 pack-objects: plug leak in `read_stdin_packs()`Taylor Blau, Mar 27, 2026
  36. 2/5 pack-objects: refactor `read_packs_list_from_stdin()` to use `strmap`Taylor Blau, Mar 27, 2026
  37. 3/5 t7704: demonstrate failure with once-cruft objects above the geometric splitTaylor Blau, Mar 27, 2026
  38. 4/5 pack-objects: support excluded-open packs with --stdin-packsTaylor Blau, Mar 27, 2026
  39. 5/5 repack: mark non-MIDX packs above the split as excluded-openTaylor Blau, Mar 27, 2026
  40. Derrick StoleeMar 27, 2026
  41. Junio C HamanoMar 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.