config: don't have setters depend on `the_repository`

Some of the setters that accept a `struct repository` still implicitly rely on `the_repository` via `git_config_set_multivar_in_file()`. While this function would typically use the caller-provided path, it knows to fall back to using the configuration path indicated by `the_repository`. Adapt those functions to instead use the caller-provided repository. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Aug 13, 2024 at 11:14 UTC c2ba4e3b5c8c1280bd3d3623b27e9ed66c788f09
1 file changed +8 -8
config.c
+8 -8
@@ -3220,8 +3220,8 @@ int repo_config_set_worktree_gently(struct repository *r,
3220 /* Only use worktree-specific config if it is already enabled. */
3221 if (r->repository_format_worktree_config) {
3222 char *file = repo_git_path(r, "config.worktree");
3223 - int ret = git_config_set_multivar_in_file_gently(
3224 - file, key, value, NULL, NULL, 0);
3223 + int ret = repo_config_set_multivar_in_file_gently(
3224 + r, file, key, value, NULL, NULL, 0);
3225 free(file);
3226 return ret;
3227 }
@@ -3613,10 +3613,10 @@ int repo_config_set_multivar_gently(struct repository *r, const char *key,
3613 const char *value_pattern, unsigned flags)
3614 {
3615 char *file = repo_git_path(r, "config");
3616 - int res = git_config_set_multivar_in_file_gently(file,
3617 - key, value,
3618 - value_pattern,
3619 - NULL, flags);
3616 + int res = repo_config_set_multivar_in_file_gently(r, file,
3617 + key, value,
3618 + value_pattern,
3619 + NULL, flags);
3620 free(file);
3621 return res;
3622 }
@@ -3626,8 +3626,8 @@ void repo_config_set_multivar(struct repository *r,
3626 const char *value_pattern, unsigned flags)
3627 {
3628 char *file = repo_git_path(r, "config");
3629 - git_config_set_multivar_in_file(file, key, value,
3630 - value_pattern, flags);
3629 + repo_config_set_multivar_in_file(r, file, key, value,
3630 + value_pattern, flags);
3631 free(file);
3632 }
3633