Skip to content

Commit e957ed2

Browse files
pks-tgitster
authored andcommitted
config: drop git_config_set() 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()`. 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b1659e6 commit e957ed2

File tree

9 files changed

+36
-41
lines changed

9 files changed

+36
-41
lines changed

builtin/branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ static int edit_branch_description(const char *branch_name)
699699

700700
strbuf_addf(&name, "branch.%s.description", branch_name);
701701
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);
703703
strbuf_release(&name);
704704
strbuf_release(&buf);
705705

builtin/clone.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ static void write_refspec_config(const char *src_ref_prefix,
827827

828828
if (option_mirror) {
829829
strbuf_addf(&key, "remote.%s.mirror", remote_name);
830-
git_config_set(key.buf, "true");
830+
repo_config_set(the_repository, key.buf, "true");
831831
strbuf_reset(&key);
832832
}
833833
}
@@ -1294,18 +1294,18 @@ int cmd_clone(int argc,
12941294
src_ref_prefix = "refs/";
12951295
strbuf_addstr(&branch_top, src_ref_prefix);
12961296

1297-
git_config_set("core.bare", "true");
1297+
repo_config_set(the_repository, "core.bare", "true");
12981298
} else if (!option_rev) {
12991299
strbuf_addf(&branch_top, "refs/remotes/%s/", remote_name);
13001300
}
13011301

13021302
strbuf_addf(&key, "remote.%s.url", remote_name);
1303-
git_config_set(key.buf, repo);
1303+
repo_config_set(the_repository, key.buf, repo);
13041304
strbuf_reset(&key);
13051305

13061306
if (!option_tags) {
13071307
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");
13091309
strbuf_reset(&key);
13101310
}
13111311

builtin/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,11 +1913,11 @@ static int maintenance_register(int argc, const char **argv, const char *prefix,
19131913
options);
19141914

19151915
/* Disable foreground maintenance */
1916-
git_config_set("maintenance.auto", "false");
1916+
repo_config_set(the_repository, "maintenance.auto", "false");
19171917

19181918
/* Set maintenance strategy, if unset */
19191919
if (repo_config_get(the_repository, "maintenance.strategy"))
1920-
git_config_set("maintenance.strategy", "incremental");
1920+
repo_config_set(the_repository, "maintenance.strategy", "incremental");
19211921

19221922
if (!repo_config_get_string_multi(the_repository, key, &list)) {
19231923
for_each_string_list_item(item, list) {

builtin/remote.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static int add(int argc, const char **argv, const char *prefix,
209209
die(_("'%s' is not a valid remote name"), name);
210210

211211
strbuf_addf(&buf, "remote.%s.url", name);
212-
git_config_set(buf.buf, url);
212+
repo_config_set(the_repository, buf.buf, url);
213213

214214
if (!mirror || mirror & MIRROR_FETCH) {
215215
strbuf_reset(&buf);
@@ -225,14 +225,14 @@ static int add(int argc, const char **argv, const char *prefix,
225225
if (mirror & MIRROR_PUSH) {
226226
strbuf_reset(&buf);
227227
strbuf_addf(&buf, "remote.%s.mirror", name);
228-
git_config_set(buf.buf, "true");
228+
repo_config_set(the_repository, buf.buf, "true");
229229
}
230230

231231
if (fetch_tags != TAGS_DEFAULT) {
232232
strbuf_reset(&buf);
233233
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");
236236
}
237237

238238
if (fetch && fetch_remote(name)) {
@@ -802,12 +802,12 @@ static int mv(int argc, const char **argv, const char *prefix,
802802
if (info->remote_name && !strcmp(info->remote_name, rename.old_name)) {
803803
strbuf_reset(&buf);
804804
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);
806806
}
807807
if (info->push_remote_name && !strcmp(info->push_remote_name, rename.old_name)) {
808808
strbuf_reset(&buf);
809809
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);
811811
}
812812
}
813813

@@ -1503,7 +1503,7 @@ static int set_head(int argc, const char **argv, const char *prefix,
15031503
struct strbuf config_name = STRBUF_INIT;
15041504
strbuf_addf(&config_name,
15051505
"remote.%s.followremotehead", remote->name);
1506-
git_config_set(config_name.buf, "warn");
1506+
repo_config_set(the_repository, config_name.buf, "warn");
15071507
strbuf_release(&config_name);
15081508
}
15091509

@@ -1793,7 +1793,7 @@ static int set_url(int argc, const char **argv, const char *prefix,
17931793
git_config_set_multivar(name_buf.buf, newurl,
17941794
"^$", 0);
17951795
else
1796-
git_config_set(name_buf.buf, newurl);
1796+
repo_config_set(the_repository, name_buf.buf, newurl);
17971797
goto out;
17981798
}
17991799

compat/precompose_utf8.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ void probe_utf8_pathname_composition(void)
5656
close(output_fd);
5757
repo_git_path_replace(the_repository, &path, "%s", auml_nfd);
5858
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");
6161
repo_git_path_replace(the_repository, &path, "%s", auml_nfc);
6262
if (unlink(path.buf))
6363
die_errno(_("failed to unlink '%s'"), path.buf);

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,7 @@ void git_die_config(struct repository *r, const char *key, const char *err, ...)
27482748
}
27492749

27502750
/*
2751-
* Find all the stuff for git_config_set() below.
2751+
* Find all the stuff for repo_config_set() below.
27522752
*/
27532753

27542754
struct config_store_data {

config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +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(const char *key, const char *value)
738-
{
739-
repo_config_set(the_repository, key, value);
740-
}
741-
742737
static inline int git_config_set_in_file_gently(
743738
const char *config_filename,
744739
const char *key,

list-objects-filter-options.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ void partial_clone_register(
350350

351351
/* Add promisor config for the remote */
352352
cfg_name = xstrfmt("remote.%s.promisor", remote);
353-
git_config_set(cfg_name, "true");
353+
repo_config_set(the_repository, cfg_name, "true");
354354
free(cfg_name);
355355
}
356356

@@ -360,8 +360,8 @@ void partial_clone_register(
360360
*/
361361
filter_name = xstrfmt("remote.%s.partialclonefilter", remote);
362362
/* 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));
365365
free(filter_name);
366366

367367
/* Make sure the config info are reset */

setup.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ int upgrade_repository_format(int target_version)
815815
}
816816

817817
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);
819819

820820
ret = 1;
821821

@@ -2233,14 +2233,14 @@ void initialize_repository_version(int hash_algo,
22332233
target_version = GIT_REPO_VERSION_READ;
22342234

22352235
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);
22382238
else if (reinit)
22392239
repo_config_set_gently(the_repository, "extensions.objectformat", NULL);
22402240

22412241
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));
22442244
else if (reinit)
22452245
repo_config_set_gently(the_repository, "extensions.refstorage", NULL);
22462246

@@ -2259,7 +2259,7 @@ void initialize_repository_version(int hash_algo,
22592259
}
22602260

22612261
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);
22632263

22642264
strbuf_release(&repo_version);
22652265
}
@@ -2375,17 +2375,17 @@ static int create_default_files(const char *template_path,
23752375
if (filemode && !reinit && (st1.st_mode & S_IXUSR))
23762376
filemode = 0;
23772377
}
2378-
git_config_set("core.filemode", filemode ? "true" : "false");
2378+
repo_config_set(the_repository, "core.filemode", filemode ? "true" : "false");
23792379

23802380
if (is_bare_repository())
2381-
git_config_set("core.bare", "true");
2381+
repo_config_set(the_repository, "core.bare", "true");
23822382
else {
2383-
git_config_set("core.bare", "false");
2383+
repo_config_set(the_repository, "core.bare", "false");
23842384
/* allow template config file to override the default */
23852385
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");
23872387
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);
23892389
}
23902390

23912391
if (!reinit) {
@@ -2398,12 +2398,12 @@ static int create_default_files(const char *template_path,
23982398
S_ISLNK(st1.st_mode))
23992399
unlink(path.buf); /* good */
24002400
else
2401-
git_config_set("core.symlinks", "false");
2401+
repo_config_set(the_repository, "core.symlinks", "false");
24022402

24032403
/* Check if the filesystem is case-insensitive */
24042404
repo_git_path_replace(the_repository, &path, "CoNfIg");
24052405
if (!access(path.buf, F_OK))
2406-
git_config_set("core.ignorecase", "true");
2406+
repo_config_set(the_repository, "core.ignorecase", "true");
24072407
probe_utf8_pathname_composition();
24082408
}
24092409

@@ -2639,8 +2639,8 @@ int init_db(const char *git_dir, const char *real_git_dir,
26392639
xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_EVERYBODY);
26402640
else
26412641
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");
26442644
}
26452645

26462646
if (!(flags & INIT_DB_QUIET)) {

0 commit comments

Comments
 (0)