From: Derrick Stolee <stolee@gmail.com>
To: Taylor Blau <me@ttaylorr.com>, git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
Elijah Newren <newren@gmail.com>, Patrick Steinhardt <ps@pks.im>
Subject: Re: [PATCH v2 2/5] pack-objects: refactor `read_packs_list_from_stdin()` to use `strmap`
Date: Thu, 26 Mar 2026 16:40:00 -0400 [thread overview]
Message-ID: <9e320604-7367-4f48-a943-f7d22feb2672@gmail.com> (raw)
In-Reply-To: <d5cb793f0eb0028f1f521fec4723ad2b00592638.1774482701.git.me@ttaylorr.com>
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.
> +static void stdin_packs_read_input(struct rev_info *revs)
> {
> struct strbuf buf = STRBUF_INIT;
> - struct string_list include_packs = STRING_LIST_INIT_DUP;
> - struct string_list exclude_packs = STRING_LIST_INIT_DUP;
> - struct string_list_item *item = NULL;
> + struct strmap packs = STRMAP_INIT;
> struct packed_git *p;
>
> while (strbuf_getline(&buf, stdin) != EOF) {
> - if (!buf.len)
> + struct stdin_pack_info *info;
> + const char *key = buf.buf;
> +
> + if (!*key)
> continue;
> + if (*key == '^')
> + key++;...
> if (*buf.buf == '^')
> - string_list_append(&exclude_packs, buf.buf + 1);
> + info->kind |= STDIN_PACK_EXCLUDE_CLOSED;
> else
> - string_list_append(&include_packs, buf.buf);
> + info->kind |= STDIN_PACK_INCLUDE;
>
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.
> strbuf_reset(&buf);
> }
>
> - string_list_sort_u(&include_packs, 0);
> - string_list_sort_u(&exclude_packs, 0);
> -
> repo_for_each_pack(the_repository, p) {
> - const char *pack_name = pack_basename(p);
> + struct stdin_pack_info *info;
>
> - if ((item = string_list_lookup(&include_packs, pack_name))) {
> + info = strmap_get(&packs, pack_basename(p));
> + if (!info)
> + continue;
> +
> + if (info->kind & STDIN_PACK_INCLUDE) {
...
> }
> + if (info->kind & STDIN_PACK_EXCLUDE_CLOSED) {
This does help confirm that a pack could be in both categories, so
using flag bits helps.
Thanks,
-Stolee
next prev parent reply other threads:[~2026-03-26 20:40 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 22:24 [PATCH 0/5] pack-objects: handle excluded-but-open packs via `--stdin-packs=follow` Taylor Blau
2026-03-19 22:24 ` [PATCH 1/5] pack-objects: plug leak in `read_stdin_packs()` Taylor Blau
2026-03-24 7:39 ` Patrick Steinhardt
2026-03-25 23:03 ` Taylor Blau
2026-03-19 22:24 ` [PATCH 2/5] pack-objects: refactor `read_packs_list_from_stdin()` to use `strmap` Taylor Blau
2026-03-24 7:39 ` Patrick Steinhardt
2026-03-25 23:13 ` Taylor Blau
2026-03-19 22:24 ` [PATCH 3/5] t7704: demonstrate failure with once-cruft objects above the geometric split Taylor Blau
2026-03-19 22:24 ` [PATCH 4/5] pack-objects: support excluded-open packs with --stdin-packs Taylor Blau
2026-03-21 16:57 ` Jeff King
2026-03-22 18:09 ` Taylor Blau
2026-03-25 23:19 ` Taylor Blau
2026-03-19 22:24 ` [PATCH 5/5] repack: mark non-MIDX packs above the split as excluded-open Taylor Blau
2026-03-25 23:51 ` [PATCH v2 0/5] pack-objects: handle excluded-but-open packs via `--stdin-packs=follow` Taylor Blau
2026-03-25 23:51 ` [PATCH v2 1/5] pack-objects: plug leak in `read_stdin_packs()` Taylor Blau
2026-03-25 23:51 ` [PATCH v2 2/5] pack-objects: refactor `read_packs_list_from_stdin()` to use `strmap` Taylor Blau
2026-03-26 20:40 ` Derrick Stolee [this message]
2026-03-26 21:44 ` Taylor Blau
2026-03-26 22:11 ` Junio C Hamano
2026-03-26 22:32 ` Taylor Blau
2026-03-27 0:29 ` Derrick Stolee
2026-03-27 17:51 ` Taylor Blau
2026-03-27 18:34 ` Derrick Stolee
2026-03-27 15:52 ` Junio C Hamano
2026-03-26 22:37 ` Taylor Blau
2026-03-25 23:51 ` [PATCH v2 3/5] t7704: demonstrate failure with once-cruft objects above the geometric split Taylor Blau
2026-03-25 23:51 ` [PATCH v2 4/5] pack-objects: support excluded-open packs with --stdin-packs Taylor Blau
2026-03-26 20:48 ` Derrick Stolee
2026-03-25 23:51 ` [PATCH v2 5/5] repack: mark non-MIDX packs above the split as excluded-open Taylor Blau
2026-03-26 20:49 ` Derrick Stolee
2026-03-26 21:44 ` Taylor Blau
2026-03-26 20:51 ` [PATCH v2 0/5] pack-objects: handle excluded-but-open packs via `--stdin-packs=follow` Derrick Stolee
2026-03-26 21:46 ` Taylor Blau
2026-03-27 20:06 ` [PATCH v3 " Taylor Blau
2026-03-27 20:06 ` [PATCH v3 1/5] pack-objects: plug leak in `read_stdin_packs()` Taylor Blau
2026-03-27 20:06 ` [PATCH v3 2/5] pack-objects: refactor `read_packs_list_from_stdin()` to use `strmap` Taylor Blau
2026-03-27 20:06 ` [PATCH v3 3/5] t7704: demonstrate failure with once-cruft objects above the geometric split Taylor Blau
2026-03-27 20:06 ` [PATCH v3 4/5] pack-objects: support excluded-open packs with --stdin-packs Taylor Blau
2026-03-27 20:06 ` [PATCH v3 5/5] repack: mark non-MIDX packs above the split as excluded-open Taylor Blau
2026-03-27 20:16 ` [PATCH v3 0/5] pack-objects: handle excluded-but-open packs via `--stdin-packs=follow` Derrick Stolee
2026-03-27 20:43 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9e320604-7367-4f48-a943-f7d22feb2672@gmail.com \
--to=stolee@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox