Skip to content

Commit 122e38c

Browse files
pks-tgitster
authored andcommitted
config: drop git_config_set_in_file() wrapper
In 036876a (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5d215a7 commit 122e38c

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

builtin/submodule--helper.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,12 +1810,12 @@ static int clone_submodule(const struct module_clone_data *clone_data,
18101810
/* setup alternateLocation and alternateErrorStrategy in the cloned submodule if needed */
18111811
repo_config_get_string(the_repository, "submodule.alternateLocation", &sm_alternate);
18121812
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);
18151815
repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy);
18161816
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);
18191819

18201820
free(sm_alternate);
18211821
free(error_strategy);
@@ -2522,7 +2522,7 @@ static int ensure_core_worktree(const char *path)
25222522
abs_path = absolute_pathdup(path);
25232523
rel_path = relative_path(abs_path, subrepo.gitdir, &sb);
25242524

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);
25262526

25272527
free(cfg_file);
25282528
free(abs_path);

config.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,12 +734,6 @@ static inline int git_config_get_pathname(const char *key, char **dest)
734734
return repo_config_get_pathname(the_repository, key, dest);
735735
}
736736

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-
743737
static inline int git_config_set_gently(const char *key, const char *value)
744738
{
745739
return repo_config_set_gently(the_repository, key, value);

dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4091,8 +4091,8 @@ void connect_work_tree_and_git_dir(const char *work_tree_,
40914091
write_file(gitfile_sb.buf, "gitdir: %s",
40924092
relative_path(git_dir, work_tree, &rel_path));
40934093
/* 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));
40964096

40974097
strbuf_release(&gitfile_sb);
40984098
strbuf_release(&cfg_sb);

0 commit comments

Comments
 (0)