Re: [PATCH 2/3] parse_config_key: allow matching single-level config

2 messages, 2 authors, 2017-02-24 · open the first message on its own page

Re: [PATCH 2/3] parse_config_key: allow matching single-level config

From: Junio C Hamano <hidden>
Date: 2017-02-24 21:20:54

Jeff King [off-list ref] writes:
The parse_config_key() function was introduced to make it
easier to match "section.subsection.key" variables. It also
handles the simpler "section.key", and the caller is
responsible for distinguishing the two from its
out-parameters.

Most callers who _only_ want "section.key" would just use a
strcmp(var, "section.key"), since there is no parsing
required. However, they may still use parse_config_key() if
their "section" variable isn't a constant (an example of
this is in parse_hide_refs_config).
Perhaps "only" at the end of the title?

After grepping for call sites of this function, I think we can
simplify quite a few instances of:

	if (parse_config_key(...) || !name)
		return ...;

Re: [PATCH 2/3] parse_config_key: allow matching single-level config

From: Jeff King <hidden>
Date: 2017-02-24 21:28:19

On Fri, Feb 24, 2017 at 01:20:48PM -0800, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
The parse_config_key() function was introduced to make it
easier to match "section.subsection.key" variables. It also
handles the simpler "section.key", and the caller is
responsible for distinguishing the two from its
out-parameters.

Most callers who _only_ want "section.key" would just use a
strcmp(var, "section.key"), since there is no parsing
required. However, they may still use parse_config_key() if
their "section" variable isn't a constant (an example of
this is in parse_hide_refs_config).
Perhaps "only" at the end of the title?
Yeah, that would be an improvement.
After grepping for call sites of this function, I think we can
simplify quite a few instances of:

	if (parse_config_key(...) || !name)
		return ...;
I think you figured this out from your other response, but no, those are
the opposite case (it tricked me at first, too).

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help