config: drop git_config_set_multivar_in_file_gently() wrapper

In 036876a106 (config: hide functions using `the_repository` by
default, 2024-08-13) we have moved around a bunch of functions in the
config subsystem that depend on `the_repository`. Those function have
been converted into mere wrappers around their equivalent function that
takes in a repository as parameter, and the intent was that we'll
eventually remove those wrappers to make the dependency on the global
repository variable explicit at the callsite.

Follow through with that intent and remove
`git_config_set_multivar_in_file_gently()`. All callsites are adjusted
so that they use
`repo_config_set_multivar_in_file_gently(the_repository, ...)` instead.
While some callsites might already have a repository available, this
mechanical conversion is the exact same as the current situation and
thus cannot cause any regression. Those sites should eventually be
cleaned up in a later patch series.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-07-23 16:08:37 +02:00
committed by Junio C Hamano
parent 62c1ed3e9d
commit adf9e5f8f2
5 changed files with 26 additions and 38 deletions

View File

@@ -966,9 +966,9 @@ static int cmd_config_set(int argc, const char **argv, const char *prefix,
value = normalize_value(argv[0], argv[1], type, &default_kvi);
if ((flags & CONFIG_FLAGS_MULTI_REPLACE) || value_pattern) {
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
argv[0], value, value_pattern,
comment, flags);
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
argv[0], value, value_pattern,
comment, flags);
} else {
ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file,
argv[0], comment, value);
@@ -1010,9 +1010,9 @@ static int cmd_config_unset(int argc, const char **argv, const char *prefix,
check_write(&location_opts.source);
if ((flags & CONFIG_FLAGS_MULTI_REPLACE) || value_pattern)
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
argv[0], NULL, value_pattern,
NULL, flags);
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
argv[0], NULL, value_pattern,
NULL, flags);
else
ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, argv[0],
NULL, NULL);
@@ -1305,26 +1305,26 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
check_write(&location_opts.source);
check_argc(argc, 2, 3);
value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi);
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
argv[0], value, argv[2],
comment, flags);
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
argv[0], value, argv[2],
comment, flags);
}
else if (actions == ACTION_ADD) {
check_write(&location_opts.source);
check_argc(argc, 2, 2);
value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi);
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
argv[0], value,
CONFIG_REGEX_NONE,
comment, flags);
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
argv[0], value,
CONFIG_REGEX_NONE,
comment, flags);
}
else if (actions == ACTION_REPLACE_ALL) {
check_write(&location_opts.source);
check_argc(argc, 2, 3);
value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi);
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
argv[0], value, argv[2],
comment, flags | CONFIG_FLAGS_MULTI_REPLACE);
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
argv[0], value, argv[2],
comment, flags | CONFIG_FLAGS_MULTI_REPLACE);
}
else if (actions == ACTION_GET) {
check_argc(argc, 1, 2);
@@ -1350,9 +1350,9 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
check_write(&location_opts.source);
check_argc(argc, 1, 2);
if (argc == 2)
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
argv[0], NULL, argv[1],
NULL, flags);
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
argv[0], NULL, argv[1],
NULL, flags);
else
ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file,
argv[0], NULL, NULL);
@@ -1360,9 +1360,9 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
else if (actions == ACTION_UNSET_ALL) {
check_write(&location_opts.source);
check_argc(argc, 1, 2);
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
argv[0], NULL, argv[1],
NULL, flags | CONFIG_FLAGS_MULTI_REPLACE);
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
argv[0], NULL, argv[1],
NULL, flags | CONFIG_FLAGS_MULTI_REPLACE);
}
else if (actions == ACTION_RENAME_SECTION) {
check_write(&location_opts.source);

View File

@@ -1938,7 +1938,7 @@ static int maintenance_register(int argc, const char **argv, const char *prefix,
}
if (!config_file)
die(_("$HOME not set"));
rc = git_config_set_multivar_in_file_gently(
rc = repo_config_set_multivar_in_file_gently(the_repository,
config_file, "maintenance.repo", maintpath,
CONFIG_REGEX_NONE, NULL, 0);
free(global_config_file);
@@ -2007,7 +2007,7 @@ static int maintenance_unregister(int argc, const char **argv, const char *prefi
}
if (!config_file)
die(_("$HOME not set"));
rc = git_config_set_multivar_in_file_gently(
rc = repo_config_set_multivar_in_file_gently(the_repository,
config_file, key, NULL, maintpath, NULL,
CONFIG_FLAGS_MULTI_REPLACE | CONFIG_FLAGS_FIXED_VALUE);
free(global_config_file);

View File

@@ -379,7 +379,7 @@ static void copy_filtered_worktree_config(const char *worktree_git_dir)
if (!git_configset_get_bool(&cs, "core.bare", &bare) &&
bare &&
git_config_set_multivar_in_file_gently(
repo_config_set_multivar_in_file_gently(the_repository,
to_file, "core.bare", NULL, "true", NULL, 0))
error(_("failed to unset '%s' in '%s'"),
"core.bare", to_file);

View File

@@ -734,18 +734,6 @@ static inline int git_config_get_pathname(const char *key, char **dest)
return repo_config_get_pathname(the_repository, key, dest);
}
static inline int git_config_set_multivar_in_file_gently(
const char *config_filename,
const char *key, const char *value,
const char *value_pattern,
const char *comment,
unsigned flags)
{
return repo_config_set_multivar_in_file_gently(the_repository, config_filename,
key, value, value_pattern,
comment, flags);
}
static inline void git_config_set_multivar_in_file(
const char *config_filename,
const char *key,

View File

@@ -3690,7 +3690,7 @@ static int save_opts(struct replay_opts *opts)
res |= repo_config_set_in_file_gently(the_repository, opts_file,
"options.gpg-sign", NULL, opts->gpg_sign);
for (size_t i = 0; i < opts->xopts.nr; i++)
res |= git_config_set_multivar_in_file_gently(opts_file,
res |= repo_config_set_multivar_in_file_gently(the_repository, opts_file,
"options.strategy-option",
opts->xopts.v[i], "^$", NULL, 0);
if (opts->allow_rerere_auto)