Re: [PATCH v3 3/3] rebase: add a config option for --rebase-merges
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 23, 2023, 00:12 UTC
- Message-ID
- <xmqqh6vdb5pm.fsf@gitster.g>
- In-Reply-To
- <20230222051709.464275-3-alexhenrie24@gmail.com>
Alex Henrie <alexhenrie24@gmail.com> writes:
Show 9 quoted lines
> +rebase.merges:: > + Whether and how to set the `--rebase-merges` option by default. Can > + be `rebase-cousins`, `no-rebase-cousins`, or a boolean. Setting to > + true is equivalent to `--rebase-merges` without an argument, setting to > + `rebase-cousins` or `no-rebase-cousins` is equivalent to > + `--rebase-merges` with that value as its argument, and setting to false > + is equivalent to `--no-rebase-merges`. Passing `--rebase-merges` on the > + command line without an argument overrides a `rebase.merges=false` > + configuration but does not override other values of `rebase.merge`.
OK. And ...
Show 13 quoted lines
> +static void parse_merges_value(struct rebase_options *options, const char *value)
> +{
> + if (value) {
> + if (!strcmp("no-rebase-cousins", value))
> + options->rebase_cousins = 0;
> + else if (!strcmp("rebase-cousins", value))
> + options->rebase_cousins = 1;
> + else
> + die(_("Unknown mode: %s"), value);
> + }
> +
> + options->rebase_merges = 1;
> +}... this fallback parsing that is called after parse_maybe_bool() finds the value a non-Boolean ...
Show 10 quoted lines
> @@ -815,6 +829,13 @@ static int rebase_config(const char *var, const char *value, void *data)
> return 0;
> }
>
> + if (!strcmp(var, "rebase.merges") && value && *value) {
> + opts->rebase_merges = git_parse_maybe_bool(value);
> + if (opts->rebase_merges < 0)
> + parse_merges_value(opts, value);
> + return 0;
> + }... looks pretty much standard way to handle such an "extended Boolean" value. Nicely done.