Re: [PATCH 1/3] git-compat-util: introduce skip_to_opt_val()

2017-12-04 Thread Junio C Hamano
Christian Couder writes: > In the few cases where do_something() accepts NULL and does something > different with it, the former can be changed to: > > if (skip_to_optional_val(arg, "--key", , NULL) /* the last > argument is the default value */ >

Re: [PATCH 1/3] git-compat-util: introduce skip_to_opt_val()

2017-12-03 Thread Christian Couder
On Sun, Dec 3, 2017 at 11:48 PM, Junio C Hamano wrote: > Christian Couder writes: > >> Anyway there is a design choice to be made. Adding a "const char >> *default" argument makes the function more generic,... > > I didn't suggest anything of that

Re: [PATCH 1/3] git-compat-util: introduce skip_to_opt_val()

2017-12-03 Thread Junio C Hamano
Christian Couder writes: > Anyway there is a design choice to be made. Adding a "const char > *default" argument makes the function more generic,... I didn't suggest anything of that sort, and I do not understand why you are repeatedly talking about "default" that

Re: [PATCH 1/3] git-compat-util: introduce skip_to_opt_val()

2017-12-03 Thread Christian Couder
On Sun, Dec 3, 2017 at 7:45 PM, Junio C Hamano wrote: > Christian Couder writes: > >> From: Christian Couder >> >> We often accept both a "--key" option and a "--key=" option. >> >> These options currently are parsed

Re: [PATCH 1/3] git-compat-util: introduce skip_to_opt_val()

2017-12-03 Thread Junio C Hamano
Christian Couder writes: > 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 */ > }

[PATCH 1/3] git-compat-util: introduce skip_to_opt_val()

2017-12-03 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=", )) { /* do something