Thread (1 message) 1 message, 1 author, 2017-12-11

Re: [PATCH v3 1/7] git-compat-util: introduce skip_to_optional_arg()

From: Junio C Hamano <hidden>
Date: 2017-12-11 23:23:22

Jeff King [off-list ref] writes:
  +       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.

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