Re: [PATCH v2 4/7] config: add --fixed-value option, un-implemented
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 23, 2020, 19:37 UTC
- Message-ID
- <xmqq1rgjoodx.fsf@gitster.c.googlers.com>
- In-Reply-To
- <0e6a7371ed4696f6cc85df07466fb6c20d58d62e.1606147507.git.gitgitgadget@gmail.com>
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 16 quoted lines
> + if (fixed_value) {
> + int allowed_usage = 0;
> +
> + switch (actions) {
> + case ACTION_GET:
> + case ACTION_GET_ALL:
> + case ACTION_GET_REGEXP:
> + case ACTION_UNSET:
> + case ACTION_UNSET_ALL:
> + allowed_usage = argc > 1 && !!argv[1];
> + break;
> +
> + case ACTION_SET_ALL:
> + case ACTION_REPLACE_ALL:
> + allowed_usage = argc > 2 && !!argv[2];
> + break;Implicitly all other ops do not want to work with the --fixed-value option, which makes sense.
Show 7 quoted lines
> + }
> +
> + if (!allowed_usage) {
> + error(_("--fixed-value only applies with 'value_regex'"));
> + usage_builtin_config();
> + }
> + }I was afraid that abandoning the bitmask based approach of the previous round may bloat the code but seeing the result here makes me quite happy ;-) It is quite clear what is going on.
Nice.