From: Junio C Hamano Date: Sun, 01 Nov 2026 00:52:51 GMT Subject: Re: [PATCH] merge-ort: accept rename settings given without a value Message-ID: In-Reply-To: "Thomas Bachem via GitGitGadget" writes: > From: Thomas Bachem > > "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 > "= " 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. > + 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.