Re: [PATCH v7 3/3] config: add conditional include
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 1, 2017, 17:47 UTC
- Message-ID
- <xmqqo9xkhosj.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170301112631.16497-4-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 20 quoted lines
> 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;
>
> /*
> @@ -185,6 +271,12 @@ int git_config_include(const char *var, const char *value, void *data)
>
> if (!strcmp(var, "include.path"))
> ret = handle_path_include(value, inc);
> +
> + if (!parse_config_key(var, "includeif", &cond, &cond_len, &key) &&
> + (cond && include_condition_is_true(cond, cond_len)) &&
> + !strcmp(key, "path"))
> + ret = handle_path_include(value, inc);
> +
> return ret;
> }So "includeif.path" (misspelled one without any condition) falls through to "return ret" and gives the value we got from inc->fn(). I am OK with that (i.e. "missing condition is false").
Or we can make it go to handle_path_include(), effectively making the "include.path" a short-hand for "includeIf.path". I am also OK with that (i.e. "missing condition is true").
Or we could even have "include.[<condition>.]path" without "includeIf"? I am not sure if it is a bad idea that paints ourselves in a corner, but somehow I find it tempting.