Re: [PATCH v3 1/7] git-compat-util: introduce skip_to_optional_arg()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 11, 2017, 23:23 UTC
- Message-ID
- <xmqqmv2o4zoc.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20171210143914.GA19894@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 8 quoted lines
>
> + else if (starts_with(arg, "-B") ||
> + skip_to_optional_arg(arg, "--break-rewrites", NULL)) {
> if ((options->break_opt = diff_scoreopt_parse(arg)) == -1)
>
> So that's kind-of weird, because we are parsing "-B", etc, and then
> expecting it to be _reparsed_ by diff_scoreopt_parse. So the two
> callsites must always match.Correct. diff_scoreopt_parse() can be coaxed to fit better within this if/else if/... cascade by making it take a pointer to .break_opt field and have it return "did I handle the -B/break-rewrites?" etc., but otherwise, this shows that skip_to_optional_arg() has impedance mismatch with its current API. And the NULL thing serves as a reminder that skip_to_optional_arg() is used _only_ as a prefix check and not for parsing.