]> Kevux Git Server - rit/commitdiff
config: drop `git_config_set_in_file()` wrapper
authorPatrick Steinhardt <ps@pks.im>
Wed, 23 Jul 2025 14:08:33 +0000 (16:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Jul 2025 15:15:20 +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_in_file()`.
All callsites are adjusted so that they use
`repo_config_set_in_file(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/submodule--helper.c
config.h
dir.c

index d2ab318..0be737a 100644 (file)
@@ -1810,12 +1810,12 @@ static int clone_submodule(const struct module_clone_data *clone_data,
        /* setup alternateLocation and alternateErrorStrategy in the cloned submodule if needed */
        repo_config_get_string(the_repository, "submodule.alternateLocation", &sm_alternate);
        if (sm_alternate)
-               git_config_set_in_file(p, "submodule.alternateLocation",
-                                      sm_alternate);
+               repo_config_set_in_file(the_repository, p, "submodule.alternateLocation",
+                                       sm_alternate);
        repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy);
        if (error_strategy)
-               git_config_set_in_file(p, "submodule.alternateErrorStrategy",
-                                      error_strategy);
+               repo_config_set_in_file(the_repository, p, "submodule.alternateErrorStrategy",
+                                       error_strategy);
 
        free(sm_alternate);
        free(error_strategy);
@@ -2522,7 +2522,7 @@ static int ensure_core_worktree(const char *path)
                abs_path = absolute_pathdup(path);
                rel_path = relative_path(abs_path, subrepo.gitdir, &sb);
 
-               git_config_set_in_file(cfg_file, "core.worktree", rel_path);
+               repo_config_set_in_file(the_repository, cfg_file, "core.worktree", rel_path);
 
                free(cfg_file);
                free(abs_path);
index c9f582c..b4f79d4 100644 (file)
--- a/config.h
+++ b/config.h
@@ -734,12 +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_in_file(const char *config_filename,
-                                         const char *key, const char *value)
-{
-       repo_config_set_in_file(the_repository, config_filename, key, value);
-}
-
 static inline int git_config_set_gently(const char *key, const char *value)
 {
        return repo_config_set_gently(the_repository, key, value);
diff --git a/dir.c b/dir.c
index 02873f5..dfb4d40 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -4091,8 +4091,8 @@ void connect_work_tree_and_git_dir(const char *work_tree_,
        write_file(gitfile_sb.buf, "gitdir: %s",
                   relative_path(git_dir, work_tree, &rel_path));
        /* Update core.worktree setting */
-       git_config_set_in_file(cfg_sb.buf, "core.worktree",
-                              relative_path(work_tree, git_dir, &rel_path));
+       repo_config_set_in_file(the_repository, cfg_sb.buf, "core.worktree",
+                               relative_path(work_tree, git_dir, &rel_path));
 
        strbuf_release(&gitfile_sb);
        strbuf_release(&cfg_sb);