config: drop `git_config_set_in_file()` wrapper

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>

Patrick Steinhardt committed Jul 23, 2025 at 16:08 UTC 122e38c92f19054b0da2212ed3dcbc35c221a375
3 files changed +7 -13
builtin/submodule--helper.c
+5 -5
@@ -1810,12 +1810,12 @@ static int clone_submodule(const struct module_clone_data *clone_data,
1810 /* setup alternateLocation and alternateErrorStrategy in the cloned submodule if needed */
1811 repo_config_get_string(the_repository, "submodule.alternateLocation", &sm_alternate);
1812 if (sm_alternate)
1813 - git_config_set_in_file(p, "submodule.alternateLocation",
1814 - sm_alternate);
1813 + repo_config_set_in_file(the_repository, p, "submodule.alternateLocation",
1814 + sm_alternate);
1815 repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy);
1816 if (error_strategy)
1817 - git_config_set_in_file(p, "submodule.alternateErrorStrategy",
1818 - error_strategy);
1817 + repo_config_set_in_file(the_repository, p, "submodule.alternateErrorStrategy",
1818 + error_strategy);
1819
1820 free(sm_alternate);
1821 free(error_strategy);
@@ -2522,7 +2522,7 @@ static int ensure_core_worktree(const char *path)
2522 abs_path = absolute_pathdup(path);
2523 rel_path = relative_path(abs_path, subrepo.gitdir, &sb);
2524
2525 - git_config_set_in_file(cfg_file, "core.worktree", rel_path);
2525 + repo_config_set_in_file(the_repository, cfg_file, "core.worktree", rel_path);
2526
2527 free(cfg_file);
2528 free(abs_path);
config.h
-6
@@ -734,12 +734,6 @@ static inline int git_config_get_pathname(const char *key, char **dest)
734 return repo_config_get_pathname(the_repository, key, dest);
735 }
736
737 -static inline void git_config_set_in_file(const char *config_filename,
738 - const char *key, const char *value)
739 -{
740 - repo_config_set_in_file(the_repository, config_filename, key, value);
741 -}
742 -
737 static inline int git_config_set_gently(const char *key, const char *value)
738 {
739 return repo_config_set_gently(the_repository, key, value);
dir.c
+2 -2
@@ -4091,8 +4091,8 @@ void connect_work_tree_and_git_dir(const char *work_tree_,
4091 write_file(gitfile_sb.buf, "gitdir: %s",
4092 relative_path(git_dir, work_tree, &rel_path));
4093 /* Update core.worktree setting */
4094 - git_config_set_in_file(cfg_sb.buf, "core.worktree",
4095 - relative_path(work_tree, git_dir, &rel_path));
4094 + repo_config_set_in_file(the_repository, cfg_sb.buf, "core.worktree",
4095 + relative_path(work_tree, git_dir, &rel_path));
4096
4097 strbuf_release(&gitfile_sb);
4098 strbuf_release(&cfg_sb);