Re: [PATCH v3 13/15] git_config_set: make use of the config parser's event stream
- From
Jeff King <peff@peff.net>
- Date
- May 8, 2018, 13:42 UTC
- Message-ID
- <20180508134248.GA25513@sigill.intra.peff.net>
- In-Reply-To
- <a187a526f46b008c2e81dad6ef90c7d2ddc56044.1523262449.git.johannes.schindelin@gmx.de>
On Mon, Apr 09, 2018 at 10:32:20AM +0200, Johannes Schindelin wrote:
Show 14 quoted lines
> +static int store_aux_event(enum config_event_t type,
> + size_t begin, size_t end, void *data)
> +{
> + struct config_store_data *store = data;
> +
> + ALLOC_GROW(store->parsed, store->parsed_nr + 1, store->parsed_alloc);
> + store->parsed[store->parsed_nr].begin = begin;
> + store->parsed[store->parsed_nr].end = end;
> + store->parsed[store->parsed_nr].type = type;
> + store->parsed_nr++;
> +
> + if (type == CONFIG_EVENT_SECTION) {
> + if (cf->var.len < 2 || cf->var.buf[cf->var.len - 1] != '.')
> + BUG("Invalid section name '%s'", cf->var.buf);I triggered this BUG today while playing around. Here's a minimal reproduction:
echo '[broken' >config git config --file=config a.b c
I'm not sure if it should simply be a die() and not a BUG(), since it depends on the input. Or if it is a BUG and we expected an earlier part of the code (like the event generator) to catch this broken case before we get to this function.
-Peff