Re: [RFC] ident: support per-path configs by matching the path against a pattern
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 10, 2015, 20:23 UTC
- Message-ID
- <xmqqtwtbkbis.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <20150710164652.GA30113@peff.net>
Jeff King <peff@peff.net> writes:
Show 20 quoted lines
> Here's a sketch if anybody is inclined to pick it up and run with it.
> Note that I did not think too hard about little things like the
> de-anchoring.
> ...
> int git_config_include(const char *var, const char *value, void *data)
> {
> struct config_include_data *inc = data;
> + const char *cond, *key;
> + int cond_len;
> int ret;
>
> /*
> @@ -152,8 +188,12 @@ int git_config_include(const char *var, const char *value, void *data)
> if (ret < 0)
> return ret;
>
> - if (!strcmp(var, "include.path"))
> - ret = handle_path_include(value, inc);
> + if (!parse_config_key(var, "include", &cond, &cond_len, &key) &&
> + include_condition_is_true(cond, cond_len)) {I really like these two lines.
Whoever designed that parse_config_key() interface either is a genious or had a foresight with a crystal ball, or perhaps both.
Show 7 quoted lines
> + if (!strcmp(key, "path")) > + ret = handle_path_include(value, inc); > + /* else we do not know about this type of include; ignore */ > + } > return ret; > } >