]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: drop `git_config_set()` wrapper
authorPatrick Steinhardt <ps@pks.im>
Wed, 23 Jul 2025 14:08:35 +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()`. All
callsites are adjusted so that they use `repo_config_set(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/gc.c
builtin/remote.c
compat/precompose_utf8.c
config.c
config.h
list-objects-filter-options.c
setup.c

index 08e50bf77b3f5484ab0bbc2c3e660901e1f6e278..5de0691d18d4acd3af955efd03b4ad9b9f1b5213 100644 (file)
@@ -699,7 +699,7 @@ static int edit_branch_description(const char *branch_name)
 
        strbuf_addf(&name, "branch.%s.description", branch_name);
        if (buf.len || exists)
-               git_config_set(name.buf, buf.len ? buf.buf : NULL);
+               repo_config_set(the_repository, name.buf, buf.len ? buf.buf : NULL);
        strbuf_release(&name);
        strbuf_release(&buf);
 
index 0d7dd5e8ec9be348b1188002a354b1a07513be1e..f025a8f19e08d2b4d34e641dfc47537b702db9a3 100644 (file)
@@ -827,7 +827,7 @@ static void write_refspec_config(const char *src_ref_prefix,
 
                        if (option_mirror) {
                                strbuf_addf(&key, "remote.%s.mirror", remote_name);
-                               git_config_set(key.buf, "true");
+                               repo_config_set(the_repository, key.buf, "true");
                                strbuf_reset(&key);
                        }
                }
@@ -1294,18 +1294,18 @@ int cmd_clone(int argc,
                        src_ref_prefix = "refs/";
                strbuf_addstr(&branch_top, src_ref_prefix);
 
-               git_config_set("core.bare", "true");
+               repo_config_set(the_repository, "core.bare", "true");
        } else if (!option_rev) {
                strbuf_addf(&branch_top, "refs/remotes/%s/", remote_name);
        }
 
        strbuf_addf(&key, "remote.%s.url", remote_name);
-       git_config_set(key.buf, repo);
+       repo_config_set(the_repository, key.buf, repo);
        strbuf_reset(&key);
 
        if (!option_tags) {
                strbuf_addf(&key, "remote.%s.tagOpt", remote_name);
-               git_config_set(key.buf, "--no-tags");
+               repo_config_set(the_repository, key.buf, "--no-tags");
                strbuf_reset(&key);
        }
 
index fa62e4f262720c2013f48cf78972318c8550bec1..c0fe4e730877318d55bb373457731f82d15b2ff9 100644 (file)
@@ -1913,11 +1913,11 @@ static int maintenance_register(int argc, const char **argv, const char *prefix,
                                   options);
 
        /* Disable foreground maintenance */
-       git_config_set("maintenance.auto", "false");
+       repo_config_set(the_repository, "maintenance.auto", "false");
 
        /* Set maintenance strategy, if unset */
        if (repo_config_get(the_repository, "maintenance.strategy"))
-               git_config_set("maintenance.strategy", "incremental");
+               repo_config_set(the_repository, "maintenance.strategy", "incremental");
 
        if (!repo_config_get_string_multi(the_repository, key, &list)) {
                for_each_string_list_item(item, list) {
index 5c4dfc98afa96673e800486a039e41d74beb578d..827639e0398636ce54c9441440bd68ec8e8c6485 100644 (file)
@@ -209,7 +209,7 @@ static int add(int argc, const char **argv, const char *prefix,
                die(_("'%s' is not a valid remote name"), name);
 
        strbuf_addf(&buf, "remote.%s.url", name);
-       git_config_set(buf.buf, url);
+       repo_config_set(the_repository, buf.buf, url);
 
        if (!mirror || mirror & MIRROR_FETCH) {
                strbuf_reset(&buf);
@@ -225,14 +225,14 @@ static int add(int argc, const char **argv, const char *prefix,
        if (mirror & MIRROR_PUSH) {
                strbuf_reset(&buf);
                strbuf_addf(&buf, "remote.%s.mirror", name);
-               git_config_set(buf.buf, "true");
+               repo_config_set(the_repository, buf.buf, "true");
        }
 
        if (fetch_tags != TAGS_DEFAULT) {
                strbuf_reset(&buf);
                strbuf_addf(&buf, "remote.%s.tagOpt", name);
-               git_config_set(buf.buf,
-                              fetch_tags == TAGS_SET ? "--tags" : "--no-tags");
+               repo_config_set(the_repository, buf.buf,
+                               fetch_tags == TAGS_SET ? "--tags" : "--no-tags");
        }
 
        if (fetch && fetch_remote(name)) {
@@ -802,12 +802,12 @@ static int mv(int argc, const char **argv, const char *prefix,
                if (info->remote_name && !strcmp(info->remote_name, rename.old_name)) {
                        strbuf_reset(&buf);
                        strbuf_addf(&buf, "branch.%s.remote", item->string);
-                       git_config_set(buf.buf, rename.new_name);
+                       repo_config_set(the_repository, buf.buf, rename.new_name);
                }
                if (info->push_remote_name && !strcmp(info->push_remote_name, rename.old_name)) {
                        strbuf_reset(&buf);
                        strbuf_addf(&buf, "branch.%s.pushRemote", item->string);
-                       git_config_set(buf.buf, rename.new_name);
+                       repo_config_set(the_repository, buf.buf, rename.new_name);
                }
        }
 
@@ -1503,7 +1503,7 @@ static int set_head(int argc, const char **argv, const char *prefix,
                struct strbuf config_name = STRBUF_INIT;
                strbuf_addf(&config_name,
                        "remote.%s.followremotehead", remote->name);
-               git_config_set(config_name.buf, "warn");
+               repo_config_set(the_repository, config_name.buf, "warn");
                strbuf_release(&config_name);
        }
 
@@ -1793,7 +1793,7 @@ static int set_url(int argc, const char **argv, const char *prefix,
                        git_config_set_multivar(name_buf.buf, newurl,
                                                       "^$", 0);
                else
-                       git_config_set(name_buf.buf, newurl);
+                       repo_config_set(the_repository, name_buf.buf, newurl);
                goto out;
        }
 
index 3985ed108eb458318201a41ae03b261fb4a47084..43b3be011439ef9921b5c6a353526ff43116164f 100644 (file)
@@ -56,8 +56,8 @@ void probe_utf8_pathname_composition(void)
                close(output_fd);
                repo_git_path_replace(the_repository, &path, "%s", auml_nfd);
                precomposed_unicode = access(path.buf, R_OK) ? 0 : 1;
-               git_config_set("core.precomposeunicode",
-                              precomposed_unicode ? "true" : "false");
+               repo_config_set(the_repository, "core.precomposeunicode",
+                               precomposed_unicode ? "true" : "false");
                repo_git_path_replace(the_repository, &path, "%s", auml_nfc);
                if (unlink(path.buf))
                        die_errno(_("failed to unlink '%s'"), path.buf);
index 095a17bd4299ebe953bf22bde21d0adadb1c28e1..285cab0ce2a6a241eda779d83e513b81e670031c 100644 (file)
--- a/config.c
+++ b/config.c
@@ -2748,7 +2748,7 @@ void git_die_config(struct repository *r, const char *key, const char *err, ...)
 }
 
 /*
- * Find all the stuff for git_config_set() below.
+ * Find all the stuff for repo_config_set() below.
  */
 
 struct config_store_data {
index 90977441c3bbd57b554b6d3566f221eb182c9821..43d06c279e3ebb4c5a0d108db3a3179f5e2d1406 100644 (file)
--- a/config.h
+++ b/config.h
@@ -734,11 +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 void git_config_set(const char *key, const char *value)
-{
-       repo_config_set(the_repository, key, value);
-}
-
 static inline int git_config_set_in_file_gently(
        const char *config_filename,
        const char *key,
index 948376d42d06afa5e6a05ffb50dd88054c881597..7420bf81fe0103196f46e5850077f239a46c8e8d 100644 (file)
@@ -350,7 +350,7 @@ void partial_clone_register(
 
                /* Add promisor config for the remote */
                cfg_name = xstrfmt("remote.%s.promisor", remote);
-               git_config_set(cfg_name, "true");
+               repo_config_set(the_repository, cfg_name, "true");
                free(cfg_name);
        }
 
@@ -360,8 +360,8 @@ void partial_clone_register(
         */
        filter_name = xstrfmt("remote.%s.partialclonefilter", remote);
        /* NEEDSWORK: 'expand' result leaking??? */
-       git_config_set(filter_name,
-                      expand_list_objects_filter_spec(filter_options));
+       repo_config_set(the_repository, filter_name,
+                       expand_list_objects_filter_spec(filter_options));
        free(filter_name);
 
        /* Make sure the config info are reset */
diff --git a/setup.c b/setup.c
index a05c348dcdf8fe0f788eeede24226325c9cfd17c..98ddbf377f923b987d998ff2a9c3e33c3c8feeaf 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -815,7 +815,7 @@ int upgrade_repository_format(int target_version)
        }
 
        strbuf_addf(&repo_version, "%d", target_version);
-       git_config_set("core.repositoryformatversion", repo_version.buf);
+       repo_config_set(the_repository, "core.repositoryformatversion", repo_version.buf);
 
        ret = 1;
 
@@ -2233,14 +2233,14 @@ void initialize_repository_version(int hash_algo,
                target_version = GIT_REPO_VERSION_READ;
 
        if (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)
-               git_config_set("extensions.objectformat",
-                              hash_algos[hash_algo].name);
+               repo_config_set(the_repository, "extensions.objectformat",
+                               hash_algos[hash_algo].name);
        else if (reinit)
                repo_config_set_gently(the_repository, "extensions.objectformat", NULL);
 
        if (ref_storage_format != REF_STORAGE_FORMAT_FILES)
-               git_config_set("extensions.refstorage",
-                              ref_storage_format_to_name(ref_storage_format));
+               repo_config_set(the_repository, "extensions.refstorage",
+                               ref_storage_format_to_name(ref_storage_format));
        else if (reinit)
                repo_config_set_gently(the_repository, "extensions.refstorage", NULL);
 
@@ -2259,7 +2259,7 @@ void initialize_repository_version(int hash_algo,
        }
 
        strbuf_addf(&repo_version, "%d", target_version);
-       git_config_set("core.repositoryformatversion", repo_version.buf);
+       repo_config_set(the_repository, "core.repositoryformatversion", repo_version.buf);
 
        strbuf_release(&repo_version);
 }
@@ -2375,17 +2375,17 @@ static int create_default_files(const char *template_path,
                if (filemode && !reinit && (st1.st_mode & S_IXUSR))
                        filemode = 0;
        }
-       git_config_set("core.filemode", filemode ? "true" : "false");
+       repo_config_set(the_repository, "core.filemode", filemode ? "true" : "false");
 
        if (is_bare_repository())
-               git_config_set("core.bare", "true");
+               repo_config_set(the_repository, "core.bare", "true");
        else {
-               git_config_set("core.bare", "false");
+               repo_config_set(the_repository, "core.bare", "false");
                /* allow template config file to override the default */
                if (repo_settings_get_log_all_ref_updates(the_repository) == LOG_REFS_UNSET)
-                       git_config_set("core.logallrefupdates", "true");
+                       repo_config_set(the_repository, "core.logallrefupdates", "true");
                if (needs_work_tree_config(original_git_dir, work_tree))
-                       git_config_set("core.worktree", work_tree);
+                       repo_config_set(the_repository, "core.worktree", work_tree);
        }
 
        if (!reinit) {
@@ -2398,12 +2398,12 @@ static int create_default_files(const char *template_path,
                    S_ISLNK(st1.st_mode))
                        unlink(path.buf); /* good */
                else
-                       git_config_set("core.symlinks", "false");
+                       repo_config_set(the_repository, "core.symlinks", "false");
 
                /* Check if the filesystem is case-insensitive */
                repo_git_path_replace(the_repository, &path, "CoNfIg");
                if (!access(path.buf, F_OK))
-                       git_config_set("core.ignorecase", "true");
+                       repo_config_set(the_repository, "core.ignorecase", "true");
                probe_utf8_pathname_composition();
        }
 
@@ -2639,8 +2639,8 @@ int init_db(const char *git_dir, const char *real_git_dir,
                        xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_EVERYBODY);
                else
                        BUG("invalid value for shared_repository");
-               git_config_set("core.sharedrepository", buf);
-               git_config_set("receive.denyNonFastforwards", "true");
+               repo_config_set(the_repository, "core.sharedrepository", buf);
+               repo_config_set(the_repository, "receive.denyNonFastforwards", "true");
        }
 
        if (!(flags & INIT_DB_QUIET)) {