config: drop `git_config_set()` 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()`. All callsites are adjusted so that they use `repo_config_set(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 e957ed2b275b3fd44475bacaf3955cf451a976c4
9 files changed +36 -41
builtin/branch.c
+1 -1
@@ -699,7 +699,7 @@ static int edit_branch_description(const char *branch_name)
699
700 strbuf_addf(&name, "branch.%s.description", branch_name);
701 if (buf.len || exists)
702 - git_config_set(name.buf, buf.len ? buf.buf : NULL);
702 + repo_config_set(the_repository, name.buf, buf.len ? buf.buf : NULL);
703 strbuf_release(&name);
704 strbuf_release(&buf);
705
builtin/clone.c
+4 -4
@@ -827,7 +827,7 @@ static void write_refspec_config(const char *src_ref_prefix,
827
828 if (option_mirror) {
829 strbuf_addf(&key, "remote.%s.mirror", remote_name);
830 - git_config_set(key.buf, "true");
830 + repo_config_set(the_repository, key.buf, "true");
831 strbuf_reset(&key);
832 }
833 }
@@ -1294,18 +1294,18 @@ int cmd_clone(int argc,
1294 src_ref_prefix = "refs/";
1295 strbuf_addstr(&branch_top, src_ref_prefix);
1296
1297 - git_config_set("core.bare", "true");
1297 + repo_config_set(the_repository, "core.bare", "true");
1298 } else if (!option_rev) {
1299 strbuf_addf(&branch_top, "refs/remotes/%s/", remote_name);
1300 }
1301
1302 strbuf_addf(&key, "remote.%s.url", remote_name);
1303 - git_config_set(key.buf, repo);
1303 + repo_config_set(the_repository, key.buf, repo);
1304 strbuf_reset(&key);
1305
1306 if (!option_tags) {
1307 strbuf_addf(&key, "remote.%s.tagOpt", remote_name);
1308 - git_config_set(key.buf, "--no-tags");
1308 + repo_config_set(the_repository, key.buf, "--no-tags");
1309 strbuf_reset(&key);
1310 }
1311
builtin/gc.c
+2 -2
@@ -1913,11 +1913,11 @@ static int maintenance_register(int argc, const char **argv, const char *prefix,
1913 options);
1914
1915 /* Disable foreground maintenance */
1916 - git_config_set("maintenance.auto", "false");
1916 + repo_config_set(the_repository, "maintenance.auto", "false");
1917
1918 /* Set maintenance strategy, if unset */
1919 if (repo_config_get(the_repository, "maintenance.strategy"))
1920 - git_config_set("maintenance.strategy", "incremental");
1920 + repo_config_set(the_repository, "maintenance.strategy", "incremental");
1921
1922 if (!repo_config_get_string_multi(the_repository, key, &list)) {
1923 for_each_string_list_item(item, list) {
builtin/remote.c
+8 -8
@@ -209,7 +209,7 @@ static int add(int argc, const char **argv, const char *prefix,
209 die(_("'%s' is not a valid remote name"), name);
210
211 strbuf_addf(&buf, "remote.%s.url", name);
212 - git_config_set(buf.buf, url);
212 + repo_config_set(the_repository, buf.buf, url);
213
214 if (!mirror || mirror & MIRROR_FETCH) {
215 strbuf_reset(&buf);
@@ -225,14 +225,14 @@ static int add(int argc, const char **argv, const char *prefix,
225 if (mirror & MIRROR_PUSH) {
226 strbuf_reset(&buf);
227 strbuf_addf(&buf, "remote.%s.mirror", name);
228 - git_config_set(buf.buf, "true");
228 + repo_config_set(the_repository, buf.buf, "true");
229 }
230
231 if (fetch_tags != TAGS_DEFAULT) {
232 strbuf_reset(&buf);
233 strbuf_addf(&buf, "remote.%s.tagOpt", name);
234 - git_config_set(buf.buf,
235 - fetch_tags == TAGS_SET ? "--tags" : "--no-tags");
234 + repo_config_set(the_repository, buf.buf,
235 + fetch_tags == TAGS_SET ? "--tags" : "--no-tags");
236 }
237
238 if (fetch && fetch_remote(name)) {
@@ -802,12 +802,12 @@ static int mv(int argc, const char **argv, const char *prefix,
802 if (info->remote_name && !strcmp(info->remote_name, rename.old_name)) {
803 strbuf_reset(&buf);
804 strbuf_addf(&buf, "branch.%s.remote", item->string);
805 - git_config_set(buf.buf, rename.new_name);
805 + repo_config_set(the_repository, buf.buf, rename.new_name);
806 }
807 if (info->push_remote_name && !strcmp(info->push_remote_name, rename.old_name)) {
808 strbuf_reset(&buf);
809 strbuf_addf(&buf, "branch.%s.pushRemote", item->string);
810 - git_config_set(buf.buf, rename.new_name);
810 + repo_config_set(the_repository, buf.buf, rename.new_name);
811 }
812 }
813
@@ -1503,7 +1503,7 @@ static int set_head(int argc, const char **argv, const char *prefix,
1503 struct strbuf config_name = STRBUF_INIT;
1504 strbuf_addf(&config_name,
1505 "remote.%s.followremotehead", remote->name);
1506 - git_config_set(config_name.buf, "warn");
1506 + repo_config_set(the_repository, config_name.buf, "warn");
1507 strbuf_release(&config_name);
1508 }
1509
@@ -1793,7 +1793,7 @@ static int set_url(int argc, const char **argv, const char *prefix,
1793 git_config_set_multivar(name_buf.buf, newurl,
1794 "^$", 0);
1795 else
1796 - git_config_set(name_buf.buf, newurl);
1796 + repo_config_set(the_repository, name_buf.buf, newurl);
1797 goto out;
1798 }
1799
compat/precompose_utf8.c
+2 -2
@@ -56,8 +56,8 @@ void probe_utf8_pathname_composition(void)
56 close(output_fd);
57 repo_git_path_replace(the_repository, &path, "%s", auml_nfd);
58 precomposed_unicode = access(path.buf, R_OK) ? 0 : 1;
59 - git_config_set("core.precomposeunicode",
60 - precomposed_unicode ? "true" : "false");
59 + repo_config_set(the_repository, "core.precomposeunicode",
60 + precomposed_unicode ? "true" : "false");
61 repo_git_path_replace(the_repository, &path, "%s", auml_nfc);
62 if (unlink(path.buf))
63 die_errno(_("failed to unlink '%s'"), path.buf);
config.c
+1 -1
@@ -2748,7 +2748,7 @@ void git_die_config(struct repository *r, const char *key, const char *err, ...)
2748 }
2749
2750 /*
2751 - * Find all the stuff for git_config_set() below.
2751 + * Find all the stuff for repo_config_set() below.
2752 */
2753
2754 struct config_store_data {
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 void git_config_set(const char *key, const char *value)
738 -{
739 - repo_config_set(the_repository, key, value);
740 -}
741 -
737 static inline int git_config_set_in_file_gently(
738 const char *config_filename,
739 const char *key,
list-objects-filter-options.c
+3 -3
@@ -350,7 +350,7 @@ void partial_clone_register(
350
351 /* Add promisor config for the remote */
352 cfg_name = xstrfmt("remote.%s.promisor", remote);
353 - git_config_set(cfg_name, "true");
353 + repo_config_set(the_repository, cfg_name, "true");
354 free(cfg_name);
355 }
356
@@ -360,8 +360,8 @@ void partial_clone_register(
360 */
361 filter_name = xstrfmt("remote.%s.partialclonefilter", remote);
362 /* NEEDSWORK: 'expand' result leaking??? */
363 - git_config_set(filter_name,
364 - expand_list_objects_filter_spec(filter_options));
363 + repo_config_set(the_repository, filter_name,
364 + expand_list_objects_filter_spec(filter_options));
365 free(filter_name);
366
367 /* Make sure the config info are reset */
setup.c
+15 -15
@@ -815,7 +815,7 @@ int upgrade_repository_format(int target_version)
815 }
816
817 strbuf_addf(&repo_version, "%d", target_version);
818 - git_config_set("core.repositoryformatversion", repo_version.buf);
818 + repo_config_set(the_repository, "core.repositoryformatversion", repo_version.buf);
819
820 ret = 1;
821
@@ -2233,14 +2233,14 @@ void initialize_repository_version(int hash_algo,
2233 target_version = GIT_REPO_VERSION_READ;
2234
2235 if (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)
2236 - git_config_set("extensions.objectformat",
2237 - hash_algos[hash_algo].name);
2236 + repo_config_set(the_repository, "extensions.objectformat",
2237 + hash_algos[hash_algo].name);
2238 else if (reinit)
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));
2242 + repo_config_set(the_repository, "extensions.refstorage",
2243 + ref_storage_format_to_name(ref_storage_format));
2244 else if (reinit)
2245 repo_config_set_gently(the_repository, "extensions.refstorage", NULL);
2246
@@ -2259,7 +2259,7 @@ void initialize_repository_version(int hash_algo,
2259 }
2260
2261 strbuf_addf(&repo_version, "%d", target_version);
2262 - git_config_set("core.repositoryformatversion", repo_version.buf);
2262 + repo_config_set(the_repository, "core.repositoryformatversion", repo_version.buf);
2263
2264 strbuf_release(&repo_version);
2265 }
@@ -2375,17 +2375,17 @@ static int create_default_files(const char *template_path,
2375 if (filemode && !reinit && (st1.st_mode & S_IXUSR))
2376 filemode = 0;
2377 }
2378 - git_config_set("core.filemode", filemode ? "true" : "false");
2378 + repo_config_set(the_repository, "core.filemode", filemode ? "true" : "false");
2379
2380 if (is_bare_repository())
2381 - git_config_set("core.bare", "true");
2381 + repo_config_set(the_repository, "core.bare", "true");
2382 else {
2383 - git_config_set("core.bare", "false");
2383 + repo_config_set(the_repository, "core.bare", "false");
2384 /* allow template config file to override the default */
2385 if (repo_settings_get_log_all_ref_updates(the_repository) == LOG_REFS_UNSET)
2386 - git_config_set("core.logallrefupdates", "true");
2386 + repo_config_set(the_repository, "core.logallrefupdates", "true");
2387 if (needs_work_tree_config(original_git_dir, work_tree))
2388 - git_config_set("core.worktree", work_tree);
2388 + repo_config_set(the_repository, "core.worktree", work_tree);
2389 }
2390
2391 if (!reinit) {
@@ -2398,12 +2398,12 @@ static int create_default_files(const char *template_path,
2398 S_ISLNK(st1.st_mode))
2399 unlink(path.buf); /* good */
2400 else
2401 - git_config_set("core.symlinks", "false");
2401 + repo_config_set(the_repository, "core.symlinks", "false");
2402
2403 /* Check if the filesystem is case-insensitive */
2404 repo_git_path_replace(the_repository, &path, "CoNfIg");
2405 if (!access(path.buf, F_OK))
2406 - git_config_set("core.ignorecase", "true");
2406 + repo_config_set(the_repository, "core.ignorecase", "true");
2407 probe_utf8_pathname_composition();
2408 }
2409
@@ -2639,8 +2639,8 @@ int init_db(const char *git_dir, const char *real_git_dir,
2639 xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_EVERYBODY);
2640 else
2641 BUG("invalid value for shared_repository");
2642 - git_config_set("core.sharedrepository", buf);
2643 - git_config_set("receive.denyNonFastforwards", "true");
2642 + repo_config_set(the_repository, "core.sharedrepository", buf);
2643 + repo_config_set(the_repository, "receive.denyNonFastforwards", "true");
2644 }
2645
2646 if (!(flags & INIT_DB_QUIET)) {