Re: [PATCH v2 2/5] builtin/config.c: support `--type=<type>` as preferred alias for `--<type>`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 26, 2018, 09:49 UTC
- Message-ID
- <xmqqmuxq1emd.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <404da8bdeb9808d2dfcfdf09bc62c76195c9a08c.1524722247.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
Show 12 quoted lines
> +static int option_parse_type(const struct option *opt, const char *arg,
> + int unset)
> +{
> + /*
> + * To support '--<type>' style flags, begin with new_type equal to
> + * opt->defval.
> + */
> + int new_type = opt->defval;
> + int *to_type = opt->value;
> +
> + if (unset) {
> + *((int *) opt->value) = 0;As you moved the definition of to_type higher than the previous rounds, you can already use it here to avoid cryptic casting, i.e.
*to_type = 0;
no?
> + return 0; > + }