From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Stefan Beller <sbeller@google.com>, git@vger.kernel.org
Subject: Re: [PATCH] refs: parse_hide_refs_config to use parse_config_key
Date: Fri, 24 Feb 2017 13:18:48 -0800 [thread overview]
Message-ID: <xmqq4lzj1e4n.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170224210643.max6z2ykm3gbg7lw@sigill.intra.peff.net> (Jeff King's message of "Fri, 24 Feb 2017 16:06:44 -0500")
Jeff King <peff@peff.net> writes:
> On Fri, Feb 24, 2017 at 03:39:40PM -0500, Jeff King wrote:
>
>> This will start parsing "receive.foobar.hiderefs", which we don't want.
>> I think you need:
>>
>> !parse_config_key(var, section, &subsection, &subsection_len, &key) &&
>> !subsection &&
>> !strcmp(key, "hiderefs")
>>
>> Perhaps passing NULL for the subsection variable should cause
>> parse_config_key to return failure when there is a non-empty subsection.
>>
>> -Peff
>>
>> PS Outside of parse_config_key, this code would be nicer if it used
>> skip_prefix() instead of starts_with(). Since it's going away, I
>> don't think it matters, but I note that parse_config_key could
>> probably benefit from the same.
>
> While I'm thinking about it, here are patches to do that. The third one
> I'd probably squash into yours (after ordering it to the end).
>
> [1/3]: parse_config_key: use skip_prefix instead of starts_with
> [2/3]: parse_config_key: allow matching single-level config
> [3/3]: parse_hide_refs_config: tell parse_config_key we don't want a subsection
While you were doing that, I was grepping the call sites for
parse_config_key() and made sure that all of them are OK when fed
two level names. Most of them follow this pattern:
if (parse_config_key(k, "diff", &name, &namelen, &type) || !name)
return -1;
and ones that do not immediately check !name does either eventually
do so or have separate codepaths for handlihng two- and three-level
names.
next prev parent reply other threads:[~2017-02-24 21:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 20:33 [PATCH] refs: parse_hide_refs_config to use parse_config_key Stefan Beller
2017-02-24 20:39 ` Jeff King
2017-02-24 20:43 ` Stefan Beller
2017-02-24 20:47 ` Jeff King
2017-02-24 20:47 ` Junio C Hamano
2017-02-24 21:06 ` Jeff King
2017-02-24 21:07 ` [PATCH 1/3] parse_config_key: use skip_prefix instead of starts_with Jeff King
2017-02-24 21:08 ` [PATCH 2/3] parse_config_key: allow matching single-level config Jeff King
2017-02-24 21:20 ` Junio C Hamano
2017-02-24 21:25 ` Junio C Hamano
2017-02-24 21:26 ` Jeff King
2017-02-24 21:08 ` [PATCH 3/3] parse_hide_refs_config: tell parse_config_key we don't want a subsection Jeff King
2017-02-24 23:28 ` Stefan Beller
2017-02-24 21:18 ` Junio C Hamano [this message]
2017-02-24 21:20 ` [PATCH] refs: parse_hide_refs_config to use parse_config_key Jeff King
2017-02-24 21:24 ` 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
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=xmqq4lzj1e4n.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--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).