]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: drop `git_config_set_multivar_in_file_gently()` wrapper
authorPatrick Steinhardt <ps@pks.im>
Wed, 23 Jul 2025 14:08:37 +0000 (16:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Jul 2025 15:15:21 +0000 (08:15 -0700)
In 036876a1067 (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>
builtin/config.c
builtin/gc.c
builtin/worktree.c
config.h
sequencer.c

index f7e718c67025c59b1ad05976291ab471bee4c865..59fb113b0739268e0602a76db66c63049ab88960 100644 (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);
index c0fe4e730877318d55bb373457731f82d15b2ff9..183798f0dc966e7df0ec5f98fc78ca81a45ed31e 100644 (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);
index fd517c82c444a4115ea8931ce387377aebe5ab90..812774a5ca992c5523116811239bb5a2f505f677 100644 (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);
index 4e658e47f0a25a67b398251329e9e0d20500a6c5..e69592ada15c68f2ad477361784a43b7f702a873 100644 (file)
--- a/config.h
+++ b/config.h
@@ -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,
index 8acb699f4f2f60ee5445c75725f86b7868c29512..aaf2e4df64ed0bf93a1c6c3c319845bdf6c27595 100644 (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)