Re: [PATCH 4/4] list-objects-filter: convert filter_spec to a strbuf
- From
Derrick Stolee <derrickstolee@github.com>
- Date
- Sep 19, 2022, 17:50 UTC
- Message-ID
- <2c6fca96-6b7b-b4c4-526c-2497422d8b8f@github.com>
- In-Reply-To
- <Yx1sI8cjU/SWUKVy@coredump.intra.peff.net>
On 9/11/2022 1:03 AM, Jeff King wrote:
> - if (!filter_options->filter_spec.strdup_strings)
> + if (!filter_options->filter_spec.buf)
> BUG("filter_options not properly initialized");I couldn't figure out why this would work until I dug into STRBUF_INIT and found this:
/* * Used as the default ->buf value, so that people can always assume * buf is non NULL and ->buf is NUL terminated even for a freshly * initialized strbuf. */ char strbuf_slopbuf[1];
So, this makes sense now.
> -#define LIST_OBJECTS_FILTER_INIT { .filter_spec = STRING_LIST_INIT_DUP }
> +#define LIST_OBJECTS_FILTER_INIT { .filter_spec = STRBUF_INIT }And now this macro swap works, too.
Thanks, -Stolee