From: Thomas Gummerer <t.gummerer@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Johannes.Schindelin@gmx.de, gitster@pobox.com
Subject: Re: [PATCH v2 1/4] remote: use parse_config_key
Date: Tue, 16 Feb 2016 01:13:27 +0100 [thread overview]
Message-ID: <20160216001327.GA1831@hank> (raw)
In-Reply-To: <20160215230443.GB30631@sigill.intra.peff.net>
On 02/15, Jeff King wrote:
> On Mon, Feb 15, 2016 at 11:39:41PM +0100, Thomas Gummerer wrote:
>
> > - if (!starts_with(key, "remote."))
> > + if (parse_config_key(key, "remote", &name, &namelen, &subkey) < 0)
> > return 0;
> > - name = key + 7;
> >
> > /* Handle remote.* variables */
> > - if (!strcmp(name, "pushdefault"))
> > + if (!strcmp(subkey, "pushdefault"))
> > return git_config_string(&pushremote_name, key, value);
>
> I think this needs to become:
>
> if (!name && !strcmp(subkey, "pushdefault"))
>
> so that we do not match "remote.foo.pushdefault", which is nonsense. The
> original avoided it by conflating "name" and "subkey" at various points,
> and not parsing out the subkey until later. Making that more explicit is
> one of the things that I think is improved by your patch. :)
Good catch. I'll fix this in the re-roll.
> > /* Handle remote.<name>.* variables */
> > - if (*name == '/') {
> > + if (*(name ? name : subkey) == '/') {
> > warning("Config remote shorthand cannot begin with '/': %s",
> > - name);
> > + name ? name : subkey);
> > return 0;
> > }
> > - subkey = strrchr(name, '.');
> > - if (!subkey)
> > + if (!name)
> > return 0;
>
> I think you can bump the "if (!name)" check earlier. If it is empty, we
> know that it does not start with "/". And then you can avoid the extra
> NULL-checks.
Thanks, will change that.
> The rest of the patch looks good to me. I hadn't realized initially that
> all of the subkey compares would become "foo" and not ".foo". That makes
> the diff noisier, but IMHO the result is much better.
>
> -Peff
--
Thomas
next prev parent reply other threads:[~2016-02-16 0:13 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-15 22:39 [PATCH v2 0/4] git remote improvements Thomas Gummerer
2016-02-15 22:39 ` [PATCH v2 1/4] remote: use parse_config_key Thomas Gummerer
2016-02-15 23:04 ` Jeff King
2016-02-16 0:13 ` Thomas Gummerer [this message]
2016-02-15 22:39 ` [PATCH v2 2/4] remote: simplify remote_is_configured() Thomas Gummerer
2016-02-15 22:39 ` [PATCH v2 3/4] remote: actually check if remote exits Thomas Gummerer
2016-02-15 22:39 ` [PATCH v2 4/4] remote: use remote_is_configured() for add and rename Thomas Gummerer
2016-02-15 22:52 ` Eric Sunshine
2016-02-15 23:09 ` Jeff King
2016-02-16 0:16 ` Thomas Gummerer
2016-02-16 9:47 ` [PATCH v3 0/4] git remote improvements Thomas Gummerer
2016-02-16 9:47 ` [PATCH v3 1/4] remote: use parse_config_key Thomas Gummerer
2016-02-16 9:47 ` [PATCH v3 2/4] remote: simplify remote_is_configured() Thomas Gummerer
2016-02-16 9:47 ` [PATCH v3 3/4] remote: actually check if remote exits Thomas Gummerer
2016-02-16 9:47 ` [PATCH v3 4/4] remote: use remote_is_configured() for add and rename Thomas Gummerer
2016-02-16 15:52 ` [PATCH v3 0/4] git remote improvements Jeff King
2016-02-16 21:36 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160216001327.GA1831@hank \
--to=t.gummerer@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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.
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 NNTP newsgroup(s).