Re: [PATCH v3 3/3] rebase: add a config option for --rebase-merges
From: Junio C Hamano <hidden>
Date: 2023-02-23 00:12:10
Alex Henrie [off-list ref] writes:
+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 ...
+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 ...
quoted hunk
@@ -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.