Re: [PATCH v2 1/4] config: factor out config file stack management
- From
Jeff King <peff@peff.net>
- Date
- Mar 12, 2013, 10:52 UTC
- Message-ID
- <20130312105200.GC11340@sigill.intra.peff.net>
- In-Reply-To
- <20130310165752.GB1136@sandbox-ub.fritz.box>
On Sun, Mar 10, 2013 at 05:57:53PM +0100, Heiko Voigt wrote:
Show 29 quoted lines
> Because a config callback may start parsing a new file, the
> global context regarding the current config file is stored
> as a stack. Currently we only need to manage that stack from
> git_config_from_file. Let's factor it out to allow new
> sources of config data.
>
> [...]
>
> +static int do_config_from(struct config_file *top, config_fn_t fn, void *data)
> +{
> + int ret;
> +
> + /* push config-file parsing state stack */
> + top->prev = cf;
> + top->linenr = 1;
> + top->eof = 0;
> + strbuf_init(&top->value, 1024);
> + strbuf_init(&top->var, 1024);
> + cf = top;
> +
> + ret = git_parse_file(fn, data);
> +
> + /* pop config-file parsing state stack */
> + strbuf_release(&top->value);
> + strbuf_release(&top->var);
> + cf = top->prev;
> +
> + return ret;
> +}Can we throw in a comment at the top here with the expected usage? In particular, do_config_from is expecting the caller to have filled in certain fields (at this point, top->f and top->name), but there is nothing to make that clear.
-Peff