Re: [PATCH] push: comment on a funny unbalanced option help
- From
René Scharfe <l.s.r@web.de>
- Date
- Aug 2, 2018, 16:50 UTC
- Message-ID
- <e18e9ebb-a78c-150c-9e63-e9249eb2e96d@web.de>
- In-Reply-To
- <xmqqftzw4weq.fsf@gitster-ct.c.googlers.com>
Am 02.08.2018 um 17:31 schrieb Junio C Hamano:
Show 16 quoted lines
> René Scharfe <l.s.r@web.de> writes:
>> diff --git a/parse-options.c b/parse-options.c
>> index 7db84227ab..fadfc6a833 100644
>> --- a/parse-options.c
>> +++ b/parse-options.c
>> @@ -660,7 +660,8 @@ int parse_options(int argc, const char **argv, const char *prefix,
>> static int usage_argh(const struct option *opts, FILE *outfile)
>> {
>> const char *s;
>> - int literal = (opts->flags & PARSE_OPT_LITERAL_ARGHELP) || !opts->argh;
>> + int literal = (opts->flags & PARSE_OPT_LITERAL_ARGHELP) || !opts->argh ||
>> + (opts->argh[0] == '<' && strchr(opts->argh, '>'));
>
> You are greedier than what I thought ;-) I would have limited this
> magic to the case where argh is surrounded by "<>", but you allow
> one closing ">" anywhere, which allows us to grab more complex cases.That's what I had initially, but only one of the current cases would have benefited from that strict behavior, so it's not useful enough.
> The lack of escape hatch to decline this auto-literal magic makes me > somewhat nervous, but I do not offhand think of a reason why I do > want an arg-help string that _begins_ with '<' to be enclosed by > another set of "<>", so perhaps this is a good kind of magic.
The escape hatch is to add the extra pair manually to the argh string.
René