Re: [PATCH] merge-ort: accept rename settings given without a value
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 1, 2026, 00:52 UTC
- Message-ID
- <xmqqjymx2x0c.fsf@gitster.g>
- In-Reply-To
- <pull.2284.git.1793441202854.gitgitgadget@gmail.com>
"Thomas Bachem via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 8 quoted lines
> From: Thomas Bachem <mail@thomasbachem.com> > > "git -c merge.renames merge" fails with "missing value for > 'merge.renames'", although git(1) says that "git -c foo.bar" sets > foo.bar to true. The same happens with diff.renames and > merge.directoryRenames, and with a setting written without > "= <value>" in a config file, which git-config(1) also documents as > true. Every command that merges through merge-ort fails this way.
Searching the list archive for "valueless true" tells us that we had corrected a handful of instances of config_get_string() with a call to config_get_value() in the past half year.
And this patch seems to be in line with the other efforts to fix the same misuse.
Show 17 quoted lines
> + if (!repo_config_get_value(opt->repo, "diff.renames", &v))
> + opt->detect_renames = git_config_rename("diff.renames", v);
> + if (!repo_config_get_value(opt->repo, "merge.renames", &v))
> + opt->detect_renames = git_config_rename("merge.renames", v);
> + if (!repo_config_get_value(opt->repo, "merge.directoryrenames", &v)) {
> + int boolval = git_parse_maybe_bool(v);
> if (0 <= boolval) {
> opt->detect_directory_renames = boolval ?
> MERGE_DIRECTORY_RENAMES_TRUE :
> MERGE_DIRECTORY_RENAMES_NONE;
> - } else if (!strcasecmp(value, "conflict")) {
> + } else if (!strcasecmp(v, "conflict")) {
> opt->detect_directory_renames =
> MERGE_DIRECTORY_RENAMES_CONFLICT;
> } /* avoid erroring on values from future versions of git */
> - free(value);
> }OK. Since get_value(), unlike get_string(), lets us borrow the value as "const char *", once we used to drive git_config_rename() or compared with fixed string to turn it into an enum value, we can simply forget without calling free(), which is simpler.
Nicely done.