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

2017-12-11 Thread Junio C Hamano
Jeff King 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 i

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

2017-12-10 Thread Christian Couder
On Sun, Dec 10, 2017 at 3:39 PM, Jeff King wrote: > On Sun, Dec 10, 2017 at 09:31:18AM -0500, Jeff King wrote: > >> On Sat, Dec 09, 2017 at 09:40:07PM +0100, Christian Couder wrote: >> >> > The changes compared to v2 are: >> > >> > - s/_val/_arg/ in the name of the functions >> > - s/val/arg/

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

2017-12-10 Thread Jeff King
On Sun, Dec 10, 2017 at 09:31:18AM -0500, Jeff King wrote: > On Sat, Dec 09, 2017 at 09:40:07PM +0100, Christian Couder wrote: > > > The changes compared to v2 are: > > > > - s/_val/_arg/ in the name of the functions > > - s/val/arg/ in the name of the third argument of the functions > > -

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

2017-12-10 Thread Jeff King
On Sat, Dec 09, 2017 at 09:40:07PM +0100, Christian Couder wrote: > The changes compared to v2 are: > > - s/_val/_arg/ in the name of the functions > - s/val/arg/ in the name of the third argument of the functions > - works with NULL as third argument of the functions This whole series loo

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

2017-12-09 Thread Christian Couder
From: Christian Couder We often accept both a "--key" option and a "--key=" option. These options currently are parsed using something like: if (!strcmp(arg, "--key")) { /* do something */ } else if (skip_prefix(arg, "--key=", &arg)) { /* do something with arg */ } which is a b