config: drop `git_config_set_gently()` 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_gently()`. All callsites are adjusted so that they use `repo_config_set_gently(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 b1659e63e2c647455e877cee0aff64e089d9e2ae
8 files changed +21 -26
branch.c
+3 -3
@@ -116,7 +116,7 @@ static int install_branch_config_multiple_remotes(int flag, const char *local,
116 }
117
118 strbuf_addf(&key, "branch.%s.remote", local);
119 - if (git_config_set_gently(key.buf, origin ? origin : ".") < 0)
119 + if (repo_config_set_gently(the_repository, key.buf, origin ? origin : ".") < 0)
120 goto out_err;
121
122 strbuf_reset(&key);
@@ -127,7 +127,7 @@ static int install_branch_config_multiple_remotes(int flag, const char *local,
127 * more than one is provided, use CONFIG_REGEX_NONE to preserve what
128 * we've written so far.
129 */
130 - if (git_config_set_gently(key.buf, NULL) < 0)
130 + if (repo_config_set_gently(the_repository, key.buf, NULL) < 0)
131 goto out_err;
132 for_each_string_list_item(item, remotes)
133 if (git_config_set_multivar_gently(key.buf, item->string, CONFIG_REGEX_NONE, 0) < 0)
@@ -136,7 +136,7 @@ static int install_branch_config_multiple_remotes(int flag, const char *local,
136 if (rebasing) {
137 strbuf_reset(&key);
138 strbuf_addf(&key, "branch.%s.rebase", local);
139 - if (git_config_set_gently(key.buf, "true") < 0)
139 + if (repo_config_set_gently(the_repository, key.buf, "true") < 0)
140 goto out_err;
141 }
142 strbuf_release(&key);
builtin/clone.c
+1 -1
@@ -1467,7 +1467,7 @@ int cmd_clone(int argc,
1467 warning(_("failed to fetch objects from bundle URI '%s'"),
1468 bundle_uri);
1469 else if (has_heuristic)
1470 - git_config_set_gently("fetch.bundleuri", bundle_uri);
1470 + repo_config_set_gently(the_repository, "fetch.bundleuri", bundle_uri);
1471
1472 remote_state_clear(the_repository->remote_state);
1473 free(the_repository->remote_state);
builtin/remote.c
+4 -4
@@ -694,8 +694,8 @@ static void handle_push_default(const char* old_name, const char* new_name)
694 if (push_default.scope >= CONFIG_SCOPE_COMMAND)
695 ; /* pass */
696 else if (push_default.scope >= CONFIG_SCOPE_LOCAL) {
697 - int result = git_config_set_gently("remote.pushDefault",
698 - new_name);
697 + int result = repo_config_set_gently(the_repository, "remote.pushDefault",
698 + new_name);
699 if (new_name && result && result != CONFIG_NOTHING_SET)
700 die(_("could not set '%s'"), "remote.pushDefault");
701 else if (!new_name && result && result != CONFIG_NOTHING_SET)
@@ -934,7 +934,7 @@ static int rm(int argc, const char **argv, const char *prefix,
934 strbuf_reset(&buf);
935 strbuf_addf(&buf, "branch.%s.%s",
936 item->string, *k);
937 - result = git_config_set_gently(buf.buf, NULL);
937 + result = repo_config_set_gently(the_repository, buf.buf, NULL);
938 if (result && result != CONFIG_NOTHING_SET)
939 die(_("could not unset '%s'"), buf.buf);
940 }
@@ -942,7 +942,7 @@ static int rm(int argc, const char **argv, const char *prefix,
942 if (info->push_remote_name && !strcmp(info->push_remote_name, remote->name)) {
943 strbuf_reset(&buf);
944 strbuf_addf(&buf, "branch.%s.pushremote", item->string);
945 - result = git_config_set_gently(buf.buf, NULL);
945 + result = repo_config_set_gently(the_repository, buf.buf, NULL);
946 if (result && result != CONFIG_NOTHING_SET)
947 die(_("could not unset '%s'"), buf.buf);
948 }
builtin/submodule--helper.c
+7 -7
@@ -458,7 +458,7 @@ static void init_submodule(const char *path, const char *prefix,
458 */
459 if (!is_submodule_active(the_repository, path)) {
460 strbuf_addf(&sb, "submodule.%s.active", sub->name);
461 - git_config_set_gently(sb.buf, "true");
461 + repo_config_set_gently(the_repository, sb.buf, "true");
462 strbuf_reset(&sb);
463 }
464
@@ -484,7 +484,7 @@ static void init_submodule(const char *path, const char *prefix,
484 free(oldurl);
485 }
486
487 - if (git_config_set_gently(sb.buf, url))
487 + if (repo_config_set_gently(the_repository, sb.buf, url))
488 die(_("Failed to register url for submodule path '%s'"),
489 displaypath);
490 if (!(flags & OPT_QUIET))
@@ -506,7 +506,7 @@ static void init_submodule(const char *path, const char *prefix,
506 upd = submodule_update_type_to_string(sub->update_strategy.type);
507 }
508
509 - if (git_config_set_gently(sb.buf, upd))
509 + if (repo_config_set_gently(the_repository, sb.buf, upd))
510 die(_("Failed to register update mode for submodule path '%s'"), displaypath);
511 }
512 strbuf_release(&sb);
@@ -1262,7 +1262,7 @@ static void sync_submodule(const char *path, const char *prefix,
1262
1263 strbuf_reset(&sb);
1264 strbuf_addf(&sb, "submodule.%s.url", sub->name);
1265 - if (git_config_set_gently(sb.buf, super_config_url))
1265 + if (repo_config_set_gently(the_repository, sb.buf, super_config_url))
1266 die(_("failed to register url for submodule path '%s'"),
1267 displaypath);
1268
@@ -3309,7 +3309,7 @@ static void configure_added_submodule(struct add_data *add_data)
3309 struct child_process add_gitmodules = CHILD_PROCESS_INIT;
3310
3311 key = xstrfmt("submodule.%s.url", add_data->sm_name);
3312 - git_config_set_gently(key, add_data->realrepo);
3312 + repo_config_set_gently(the_repository, key, add_data->realrepo);
3313 free(key);
3314
3315 add_submod.git_cmd = 1;
@@ -3356,12 +3356,12 @@ static void configure_added_submodule(struct add_data *add_data)
3356 */
3357 if (!is_submodule_active(the_repository, add_data->sm_path)) {
3358 key = xstrfmt("submodule.%s.active", add_data->sm_name);
3359 - git_config_set_gently(key, "true");
3359 + repo_config_set_gently(the_repository, key, "true");
3360 free(key);
3361 }
3362 } else {
3363 key = xstrfmt("submodule.%s.active", add_data->sm_name);
3364 - git_config_set_gently(key, "true");
3364 + repo_config_set_gently(the_repository, key, "true");
3365 free(key);
3366 }
3367 }
config.h
-5
@@ -734,11 +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 int git_config_set_gently(const char *key, const char *value)
738 -{
739 - return repo_config_set_gently(the_repository, key, value);
740 -}
741 -
737 static inline void git_config_set(const char *key, const char *value)
738 {
739 repo_config_set(the_repository, key, value);
scalar.c
+2 -2
@@ -103,7 +103,7 @@ static int set_scalar_config(const struct scalar_config *config, int reconfigure
103 if ((reconfigure && config->overwrite_on_reconfigure) ||
104 repo_config_get_string(the_repository, config->key, &value)) {
105 trace2_data_string("scalar", the_repository, config->key, "created");
106 - res = git_config_set_gently(config->key, config->value);
106 + res = repo_config_set_gently(the_repository, config->key, config->value);
107 } else {
108 trace2_data_string("scalar", the_repository, config->key, "exists");
109 res = 0;
@@ -322,7 +322,7 @@ static int set_config(const char *fmt, ...)
322 value = strchr(buf.buf, '=');
323 if (value)
324 *(value++) = '\0';
325 - res = git_config_set_gently(buf.buf, value);
325 + res = repo_config_set_gently(the_repository, buf.buf, value);
326 strbuf_release(&buf);
327
328 return res;
setup.c
+2 -2
@@ -2236,13 +2236,13 @@ void initialize_repository_version(int hash_algo,
2236 git_config_set("extensions.objectformat",
2237 hash_algos[hash_algo].name);
2238 else if (reinit)
2239 - git_config_set_gently("extensions.objectformat", NULL);
2239 + repo_config_set_gently(the_repository, "extensions.objectformat", NULL);
2240
2241 if (ref_storage_format != REF_STORAGE_FORMAT_FILES)
2242 git_config_set("extensions.refstorage",
2243 ref_storage_format_to_name(ref_storage_format));
2244 else if (reinit)
2245 - git_config_set_gently("extensions.refstorage", NULL);
2245 + repo_config_set_gently(the_repository, "extensions.refstorage", NULL);
2246
2247 if (reinit) {
2248 struct strbuf config = STRBUF_INIT;
worktree.c
+2 -2
@@ -1013,7 +1013,7 @@ int init_worktree_config(struct repository *r)
1013 */
1014 if (r->repository_format_worktree_config)
1015 return 0;
1016 - if ((res = git_config_set_gently("extensions.worktreeConfig", "true")))
1016 + if ((res = repo_config_set_gently(the_repository, "extensions.worktreeConfig", "true")))
1017 return error(_("failed to set extensions.worktreeConfig setting"));
1018
1019 common_config_file = xstrfmt("%s/config", r->commondir);
@@ -1077,7 +1077,7 @@ void write_worktree_linking_files(struct strbuf dotgit, struct strbuf gitdir,
1077 if (use_relative_paths && !the_repository->repository_format_relative_worktrees) {
1078 if (upgrade_repository_format(1) < 0)
1079 die(_("unable to upgrade repository format to support relative worktrees"));
1080 - if (git_config_set_gently("extensions.relativeWorktrees", "true"))
1080 + if (repo_config_set_gently(the_repository, "extensions.relativeWorktrees", "true"))
1081 die(_("unable to set extensions.relativeWorktrees setting"));
1082 the_repository->repository_format_relative_worktrees = 1;
1083 }