]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: drop `git_config_set_multivar()` wrapper
authorPatrick Steinhardt <ps@pks.im>
Wed, 23 Jul 2025 14:08:39 +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()`.
All callsites are adjusted so that they use
`repo_config_set_multivar(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/branch.c
builtin/clone.c
builtin/remote.c
config.h

index 5de0691d18d4acd3af955efd03b4ad9b9f1b5213..fa5ced452e5bb39c15b3d16d78d24dcc9e177731 100644 (file)
@@ -987,10 +987,10 @@ int cmd_branch(int argc,
 
                strbuf_reset(&buf);
                strbuf_addf(&buf, "branch.%s.remote", branch->name);
-               git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
+               repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
                strbuf_reset(&buf);
                strbuf_addf(&buf, "branch.%s.merge", branch->name);
-               git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
+               repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
                strbuf_release(&buf);
        } else if (!noncreate_actions && argc > 0 && argc <= 2) {
                const char *branch_name = argv[0];
index 183297787cb9e33edc0cc67d188911c267661d25..c990f398ef6f37ef5c7b30941491722f633c54c8 100644 (file)
@@ -822,7 +822,7 @@ static void write_refspec_config(const char *src_ref_prefix,
                /* Configure the remote */
                if (value.len) {
                        strbuf_addf(&key, "remote.%s.fetch", remote_name);
-                       git_config_set_multivar(key.buf, value.buf, "^$", 0);
+                       repo_config_set_multivar(the_repository, key.buf, value.buf, "^$", 0);
                        strbuf_reset(&key);
 
                        if (option_mirror) {
index dd340a332592cb3cdf5ec4f8855a40682049a871..4c63a8bb5760da938b7696d0be740df6d42cd487 100644 (file)
@@ -132,7 +132,7 @@ static void add_branch(const char *key, const char *branchname,
        else
                strbuf_addf(tmp, "refs/heads/%s:refs/remotes/%s/%s",
                                branchname, remotename, branchname);
-       git_config_set_multivar(key, tmp->buf, "^$", 0);
+       repo_config_set_multivar(the_repository, key, tmp->buf, "^$", 0);
 }
 
 static const char mirror_advice[] =
@@ -634,15 +634,15 @@ static int migrate_file(struct remote *remote)
 
        strbuf_addf(&buf, "remote.%s.url", remote->name);
        for (i = 0; i < remote->url.nr; i++)
-               git_config_set_multivar(buf.buf, remote->url.v[i], "^$", 0);
+               repo_config_set_multivar(the_repository, buf.buf, remote->url.v[i], "^$", 0);
        strbuf_reset(&buf);
        strbuf_addf(&buf, "remote.%s.push", remote->name);
        for (i = 0; i < remote->push.nr; i++)
-               git_config_set_multivar(buf.buf, remote->push.items[i].raw, "^$", 0);
+               repo_config_set_multivar(the_repository, buf.buf, remote->push.items[i].raw, "^$", 0);
        strbuf_reset(&buf);
        strbuf_addf(&buf, "remote.%s.fetch", remote->name);
        for (i = 0; i < remote->fetch.nr; i++)
-               git_config_set_multivar(buf.buf, remote->fetch.items[i].raw, "^$", 0);
+               repo_config_set_multivar(the_repository, buf.buf, remote->fetch.items[i].raw, "^$", 0);
 #ifndef WITH_BREAKING_CHANGES
        if (remote->origin == REMOTE_REMOTES)
                unlink_or_warn(repo_git_path_replace(the_repository, &buf,
@@ -771,7 +771,7 @@ static int mv(int argc, const char **argv, const char *prefix,
        if (oldremote->fetch.nr) {
                strbuf_reset(&buf);
                strbuf_addf(&buf, "remote.%s.fetch", rename.new_name);
-               git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
+               repo_config_set_multivar(the_repository, buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
                strbuf_addf(&old_remote_context, ":refs/remotes/%s/", rename.old_name);
                for (i = 0; i < oldremote->fetch.nr; i++) {
                        char *ptr;
@@ -791,7 +791,7 @@ static int mv(int argc, const char **argv, const char *prefix,
                                          "\tPlease update the configuration manually if necessary."),
                                        buf2.buf);
 
-                       git_config_set_multivar(buf.buf, buf2.buf, "^$", 0);
+                       repo_config_set_multivar(the_repository, buf.buf, buf2.buf, "^$", 0);
                }
        }
 
@@ -1790,7 +1790,7 @@ static int set_url(int argc, const char **argv, const char *prefix,
        /* Special cases that add new entry. */
        if ((!oldurl && !delete_mode) || add_mode) {
                if (add_mode)
-                       git_config_set_multivar(name_buf.buf, newurl,
+                       repo_config_set_multivar(the_repository, name_buf.buf, newurl,
                                                       "^$", 0);
                else
                        repo_config_set(the_repository, name_buf.buf, newurl);
@@ -1814,10 +1814,10 @@ static int set_url(int argc, const char **argv, const char *prefix,
        regfree(&old_regex);
 
        if (!delete_mode)
-               git_config_set_multivar(name_buf.buf, newurl, oldurl, 0);
+               repo_config_set_multivar(the_repository, name_buf.buf, newurl, oldurl, 0);
        else
-               git_config_set_multivar(name_buf.buf, NULL, oldurl,
-                                       CONFIG_FLAGS_MULTI_REPLACE);
+               repo_config_set_multivar(the_repository, name_buf.buf, NULL, oldurl,
+                                        CONFIG_FLAGS_MULTI_REPLACE);
 out:
        strbuf_release(&name_buf);
        return 0;
index a90b814292c7e04261d17549aace669c4789fb4f..61774f17db33b13960817e8f57584a3fe9a90674 100644 (file)
--- a/config.h
+++ b/config.h
@@ -744,13 +744,6 @@ static inline void git_config_set_multivar_in_file(
        repo_config_set_multivar_in_file(the_repository, config_filename,
                                         key, value, value_pattern, flags);
 }
-
-static inline void git_config_set_multivar(const char *key, const char *value,
-                            const char *value_pattern, unsigned flags)
-{
-       repo_config_set_multivar(the_repository, key, value,
-                                value_pattern, flags);
-}
 # endif /* USE_THE_REPOSITORY_VARIABLE */
 
 #endif /* CONFIG_H */