git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Lars Schneider <larsxschneider@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jonathan Tan <jonathantanmy@google.com>,
	git@vger.kernel.org, sbeller@google.com
Subject: Re: [PATCH] config: preserve <subsection> case for one-shot config on the command line
Date: Thu, 16 Feb 2017 11:30:28 +0100	[thread overview]
Message-ID: <D0CDD1AC-05CA-47F3-8CB5-61EA1C6515A8@gmail.com> (raw)
In-Reply-To: <xmqqa89n10df.fsf_-_@gitster.mtv.corp.google.com>


> On 16 Feb 2017, at 00:48, Junio C Hamano <gitster@pobox.com> wrote:
> 
> The "git -c <var>=<val> cmd" mechanism is to pretend that a

The problem is also present for gitconfig variables e.g.
git config --local submodule.UPPERSUB.update none

But your patch below fixes that, too!


> configuration variable <var> is set to <val> while the cmd is
> running.  The code to do so however downcased <var> in its entirety,
> which is wrong for a three-level <section>.<subsection>.<variable>.
> 
> The <subsection> part needs to stay as-is.
> 
> Reported-by: Lars Schneider <larsxschneider@gmail.com>
> Diagnosed-by: Jonathan Tan <jonathantanmy@google.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> 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 <section> and <variable> in <section>.<variable> or
> + * <section>.<subsection>.<variable> and do so in place.  <subsection>
> + * is left intact.
> + */
> +static void canonicalize_config_variable_name(char *varname)
> +{
> +	char *dot, *cp;
> +
> +	dot = strchr(varname, '.');
minor nit:
I think it would improve readability if we call this "first_dot" ...


> +	if (dot)
> +		for (cp = varname; cp < dot; cp++)
> +			*cp = tolower(*cp);
> +	dot = strrchr(varname, '.');
... and this "last_dot"?


> +	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
> 


The patch looks good to me and fixes the problem!

Should we add a test case to this patch?
If not, do you want me to improve my test case patch [1] 
or do you want to ditch the test?

Thank you,
Lars


[1] http://public-inbox.org/git/20170215111704.78320-1-larsxschneider@gmail.com/

  reply	other threads:[~2017-02-16 10:30 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15 11:17 [BUG] submodule config does not apply to upper case submodules? Lars Schneider
2017-02-15 11:33 ` [PATCH v1] t7400: cleanup "submodule add clone shallow submodule" test Lars Schneider
2017-02-15 18:29   ` Stefan Beller
2017-02-15 18:39   ` Junio C Hamano
2017-02-15 18:14 ` [BUG] submodule config does not apply to upper case submodules? Stefan Beller
2017-02-15 18:53 ` Junio C Hamano
2017-02-15 22:54   ` Jonathan Tan
2017-02-15 23:02     ` Junio C Hamano
2017-02-15 23:11       ` Junio C Hamano
2017-02-15 23:28         ` Stefan Beller
2017-02-15 23:37           ` Junio C Hamano
2017-02-15 23:43             ` Stefan Beller
2017-02-15 23:53               ` Junio C Hamano
2017-02-16 23:22             ` Jeff King
2017-02-15 23:33         ` Jonathan Tan
2017-02-16 18:49           ` Junio C Hamano
2017-02-15 23:48         ` [PATCH] config: preserve <subsection> case for one-shot config on the command line Junio C Hamano
2017-02-16 10:30           ` Lars Schneider [this message]
2017-02-16 16:59             ` Junio C Hamano
2017-02-16 23:27             ` Jeff King
2017-02-17  1:25               ` Junio C Hamano
2017-02-20  9:58                 ` Junio C Hamano
2017-02-20 17:17                   ` Lars Schneider
2017-02-21  7:38                   ` Jeff King
2017-02-21 17:01                     ` Junio C Hamano
2017-02-21 17:17                       ` [PATCH v2] " Junio C Hamano
2017-02-21 17:50                         ` Jeff King
2017-02-21 17:57                           ` Stefan Beller
2017-02-21 18:53                   ` [PATCH] config: reject invalid VAR in 'git -c VAR=VAL command' Junio C Hamano
2017-02-21 19:15                     ` Stefan Beller
2017-02-21 20:33                       ` Junio C Hamano
2017-02-21 21:24                         ` [PATCH v2] " Junio C Hamano
2017-02-22  1:06                           ` Junio C Hamano
2017-02-23  5:58                           ` Jeff King
2017-02-23  7:19                             ` Junio C Hamano
2017-02-23 23:19                               ` Junio C Hamano
2017-02-24  0:41                                 ` Jeff King
2017-02-24  4:17                                   ` Junio C Hamano
2017-02-24  4:22                                     ` Jeff King
2017-02-24  6:08                                       ` Junio C Hamano
2017-02-24  6:10                                         ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D0CDD1AC-05CA-47F3-8CB5-61EA1C6515A8@gmail.com \
    --to=larsxschneider@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonathantanmy@google.com \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).