git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.

Previous: Christian Couder
Message 11 of 11 in “git-compat-util: introduce skip_to_optional_arg()”
  1. 1/7 git-compat-util: introduce skip_to_optional_arg()Christian Couder, Dec 9, 2017
  2. 2/7 index-pack: use skip_to_optional_arg()Christian Couder, Dec 9, 2017
  3. 3/7 diff: use skip_to_optional_arg()Christian Couder, Dec 9, 2017
  4. 4/7 diff: use skip_to_optional_arg_default()Christian Couder, Dec 9, 2017
  5. 5/7 diff: use skip_to_optional_arg_default() in parsing --relativeChristian Couder, Dec 9, 2017
  6. 6/7 diff: add tests for --relative without optional prefix valueChristian Couder, Dec 9, 2017
  7. 7/7 t4045: reindent to make helpers readableChristian Couder, Dec 9, 2017
  8. Jeff KingDec 10, 2017
  9. Jeff KingDec 10, 2017
  10. Christian CouderDec 11, 2017
  11. Junio C HamanoDec 11, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.