Skip to content

Commit adf9e5f

Browse files
pks-tgitster
authored andcommitted
config: drop git_config_set_multivar_in_file_gently() wrapper
In 036876a (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 62c1ed3 commit adf9e5f

File tree

5 files changed

+26
-38
lines changed

5 files changed

+26
-38
lines changed

builtin/config.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,9 @@ static int cmd_config_set(int argc, const char **argv, const char *prefix,
966966
value = normalize_value(argv[0], argv[1], type, &default_kvi);
967967

968968
if ((flags & CONFIG_FLAGS_MULTI_REPLACE) || value_pattern) {
969-
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
970-
argv[0], value, value_pattern,
971-
comment, flags);
969+
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
970+
argv[0], value, value_pattern,
971+
comment, flags);
972972
} else {
973973
ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file,
974974
argv[0], comment, value);
@@ -1010,9 +1010,9 @@ static int cmd_config_unset(int argc, const char **argv, const char *prefix,
10101010
check_write(&location_opts.source);
10111011

10121012
if ((flags & CONFIG_FLAGS_MULTI_REPLACE) || value_pattern)
1013-
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
1014-
argv[0], NULL, value_pattern,
1015-
NULL, flags);
1013+
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
1014+
argv[0], NULL, value_pattern,
1015+
NULL, flags);
10161016
else
10171017
ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file, argv[0],
10181018
NULL, NULL);
@@ -1305,26 +1305,26 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
13051305
check_write(&location_opts.source);
13061306
check_argc(argc, 2, 3);
13071307
value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi);
1308-
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
1309-
argv[0], value, argv[2],
1310-
comment, flags);
1308+
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
1309+
argv[0], value, argv[2],
1310+
comment, flags);
13111311
}
13121312
else if (actions == ACTION_ADD) {
13131313
check_write(&location_opts.source);
13141314
check_argc(argc, 2, 2);
13151315
value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi);
1316-
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
1317-
argv[0], value,
1318-
CONFIG_REGEX_NONE,
1319-
comment, flags);
1316+
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
1317+
argv[0], value,
1318+
CONFIG_REGEX_NONE,
1319+
comment, flags);
13201320
}
13211321
else if (actions == ACTION_REPLACE_ALL) {
13221322
check_write(&location_opts.source);
13231323
check_argc(argc, 2, 3);
13241324
value = normalize_value(argv[0], argv[1], display_opts.type, &default_kvi);
1325-
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
1326-
argv[0], value, argv[2],
1327-
comment, flags | CONFIG_FLAGS_MULTI_REPLACE);
1325+
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
1326+
argv[0], value, argv[2],
1327+
comment, flags | CONFIG_FLAGS_MULTI_REPLACE);
13281328
}
13291329
else if (actions == ACTION_GET) {
13301330
check_argc(argc, 1, 2);
@@ -1350,19 +1350,19 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
13501350
check_write(&location_opts.source);
13511351
check_argc(argc, 1, 2);
13521352
if (argc == 2)
1353-
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
1354-
argv[0], NULL, argv[1],
1355-
NULL, flags);
1353+
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
1354+
argv[0], NULL, argv[1],
1355+
NULL, flags);
13561356
else
13571357
ret = repo_config_set_in_file_gently(the_repository, location_opts.source.file,
13581358
argv[0], NULL, NULL);
13591359
}
13601360
else if (actions == ACTION_UNSET_ALL) {
13611361
check_write(&location_opts.source);
13621362
check_argc(argc, 1, 2);
1363-
ret = git_config_set_multivar_in_file_gently(location_opts.source.file,
1364-
argv[0], NULL, argv[1],
1365-
NULL, flags | CONFIG_FLAGS_MULTI_REPLACE);
1363+
ret = repo_config_set_multivar_in_file_gently(the_repository, location_opts.source.file,
1364+
argv[0], NULL, argv[1],
1365+
NULL, flags | CONFIG_FLAGS_MULTI_REPLACE);
13661366
}
13671367
else if (actions == ACTION_RENAME_SECTION) {
13681368
check_write(&location_opts.source);

builtin/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,7 @@ static int maintenance_register(int argc, const char **argv, const char *prefix,
19381938
}
19391939
if (!config_file)
19401940
die(_("$HOME not set"));
1941-
rc = git_config_set_multivar_in_file_gently(
1941+
rc = repo_config_set_multivar_in_file_gently(the_repository,
19421942
config_file, "maintenance.repo", maintpath,
19431943
CONFIG_REGEX_NONE, NULL, 0);
19441944
free(global_config_file);
@@ -2007,7 +2007,7 @@ static int maintenance_unregister(int argc, const char **argv, const char *prefi
20072007
}
20082008
if (!config_file)
20092009
die(_("$HOME not set"));
2010-
rc = git_config_set_multivar_in_file_gently(
2010+
rc = repo_config_set_multivar_in_file_gently(the_repository,
20112011
config_file, key, NULL, maintpath, NULL,
20122012
CONFIG_FLAGS_MULTI_REPLACE | CONFIG_FLAGS_FIXED_VALUE);
20132013
free(global_config_file);

builtin/worktree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static void copy_filtered_worktree_config(const char *worktree_git_dir)
379379

380380
if (!git_configset_get_bool(&cs, "core.bare", &bare) &&
381381
bare &&
382-
git_config_set_multivar_in_file_gently(
382+
repo_config_set_multivar_in_file_gently(the_repository,
383383
to_file, "core.bare", NULL, "true", NULL, 0))
384384
error(_("failed to unset '%s' in '%s'"),
385385
"core.bare", to_file);

config.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -734,18 +734,6 @@ static inline int git_config_get_pathname(const char *key, char **dest)
734734
return repo_config_get_pathname(the_repository, key, dest);
735735
}
736736

737-
static inline int git_config_set_multivar_in_file_gently(
738-
const char *config_filename,
739-
const char *key, const char *value,
740-
const char *value_pattern,
741-
const char *comment,
742-
unsigned flags)
743-
{
744-
return repo_config_set_multivar_in_file_gently(the_repository, config_filename,
745-
key, value, value_pattern,
746-
comment, flags);
747-
}
748-
749737
static inline void git_config_set_multivar_in_file(
750738
const char *config_filename,
751739
const char *key,

sequencer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3690,7 +3690,7 @@ static int save_opts(struct replay_opts *opts)
36903690
res |= repo_config_set_in_file_gently(the_repository, opts_file,
36913691
"options.gpg-sign", NULL, opts->gpg_sign);
36923692
for (size_t i = 0; i < opts->xopts.nr; i++)
3693-
res |= git_config_set_multivar_in_file_gently(opts_file,
3693+
res |= repo_config_set_multivar_in_file_gently(the_repository, opts_file,
36943694
"options.strategy-option",
36953695
opts->xopts.v[i], "^$", NULL, 0);
36963696
if (opts->allow_rerere_auto)

0 commit comments

Comments
 (0)