From: Junio C Hamano Date: Wed, 15 Feb 2017 23:48:44 GMT Subject: [PATCH] config: preserve case for one-shot config on the command line Message-ID: In-Reply-To: The "git -c = cmd" mechanism is to pretend that a configuration variable is set to while the cmd is running. The code to do so however downcased in its entirety, which is wrong for a three-level
... The part needs to stay as-is. Reported-by: Lars Schneider Diagnosed-by: Jonathan Tan Signed-off-by: Junio C Hamano --- config.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 0dfed682b8..e9b93b5304 100644 --- a/config.c +++ b/config.c @@ -199,6 +199,26 @@ void git_config_push_parameter(const char *text) strbuf_release(&env); } +/* + * downcase the
and in
. or + *
.. and do so in place. + * is left intact. + */ +static void canonicalize_config_variable_name(char *varname) +{ + char *dot, *cp; + + dot = strchr(varname, '.'); + if (dot) + for (cp = varname; cp < dot; cp++) + *cp = tolower(*cp); + dot = strrchr(varname, '.'); + if (dot) + for (cp = dot + 1; *cp; cp++) + *cp = tolower(*cp); +} + + int git_config_parse_parameter(const char *text, config_fn_t fn, void *data) { @@ -221,7 +241,7 @@ int git_config_parse_parameter(const char *text, strbuf_list_free(pair); return error("bogus config parameter: %s", text); } - strbuf_tolower(pair[0]); + canonicalize_config_variable_name(pair[0]->buf); if (fn(pair[0]->buf, value, data) < 0) { strbuf_list_free(pair); return -1; -- 2.12.0-rc1-258-g3d3d1e383b