Skip to content

Commit b1659e6

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

File tree

8 files changed

+21
-26
lines changed

8 files changed

+21
-26
lines changed

branch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static int install_branch_config_multiple_remotes(int flag, const char *local,
116116
}
117117

118118
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)
120120
goto out_err;
121121

122122
strbuf_reset(&key);
@@ -127,7 +127,7 @@ static int install_branch_config_multiple_remotes(int flag, const char *local,
127127
* more than one is provided, use CONFIG_REGEX_NONE to preserve what
128128
* we've written so far.
129129
*/
130-
if (git_config_set_gently(key.buf, NULL) < 0)
130+
if (repo_config_set_gently(the_repository, key.buf, NULL) < 0)
131131
goto out_err;
132132
for_each_string_list_item(item, remotes)
133133
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,
136136
if (rebasing) {
137137
strbuf_reset(&key);
138138
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)
140140
goto out_err;
141141
}
142142
strbuf_release(&key);

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ int cmd_clone(int argc,
14671467
warning(_("failed to fetch objects from bundle URI '%s'"),
14681468
bundle_uri);
14691469
else if (has_heuristic)
1470-
git_config_set_gently("fetch.bundleuri", bundle_uri);
1470+
repo_config_set_gently(the_repository, "fetch.bundleuri", bundle_uri);
14711471

14721472
remote_state_clear(the_repository->remote_state);
14731473
free(the_repository->remote_state);

builtin/remote.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@ static void handle_push_default(const char* old_name, const char* new_name)
694694
if (push_default.scope >= CONFIG_SCOPE_COMMAND)
695695
; /* pass */
696696
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);
699699
if (new_name && result && result != CONFIG_NOTHING_SET)
700700
die(_("could not set '%s'"), "remote.pushDefault");
701701
else if (!new_name && result && result != CONFIG_NOTHING_SET)
@@ -934,15 +934,15 @@ static int rm(int argc, const char **argv, const char *prefix,
934934
strbuf_reset(&buf);
935935
strbuf_addf(&buf, "branch.%s.%s",
936936
item->string, *k);
937-
result = git_config_set_gently(buf.buf, NULL);
937+
result = repo_config_set_gently(the_repository, buf.buf, NULL);
938938
if (result && result != CONFIG_NOTHING_SET)
939939
die(_("could not unset '%s'"), buf.buf);
940940
}
941941
}
942942
if (info->push_remote_name && !strcmp(info->push_remote_name, remote->name)) {
943943
strbuf_reset(&buf);
944944
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);
946946
if (result && result != CONFIG_NOTHING_SET)
947947
die(_("could not unset '%s'"), buf.buf);
948948
}

builtin/submodule--helper.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ static void init_submodule(const char *path, const char *prefix,
458458
*/
459459
if (!is_submodule_active(the_repository, path)) {
460460
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");
462462
strbuf_reset(&sb);
463463
}
464464

@@ -484,7 +484,7 @@ static void init_submodule(const char *path, const char *prefix,
484484
free(oldurl);
485485
}
486486

487-
if (git_config_set_gently(sb.buf, url))
487+
if (repo_config_set_gently(the_repository, sb.buf, url))
488488
die(_("Failed to register url for submodule path '%s'"),
489489
displaypath);
490490
if (!(flags & OPT_QUIET))
@@ -506,7 +506,7 @@ static void init_submodule(const char *path, const char *prefix,
506506
upd = submodule_update_type_to_string(sub->update_strategy.type);
507507
}
508508

509-
if (git_config_set_gently(sb.buf, upd))
509+
if (repo_config_set_gently(the_repository, sb.buf, upd))
510510
die(_("Failed to register update mode for submodule path '%s'"), displaypath);
511511
}
512512
strbuf_release(&sb);
@@ -1262,7 +1262,7 @@ static void sync_submodule(const char *path, const char *prefix,
12621262

12631263
strbuf_reset(&sb);
12641264
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))
12661266
die(_("failed to register url for submodule path '%s'"),
12671267
displaypath);
12681268

@@ -3309,7 +3309,7 @@ static void configure_added_submodule(struct add_data *add_data)
33093309
struct child_process add_gitmodules = CHILD_PROCESS_INIT;
33103310

33113311
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);
33133313
free(key);
33143314

33153315
add_submod.git_cmd = 1;
@@ -3356,12 +3356,12 @@ static void configure_added_submodule(struct add_data *add_data)
33563356
*/
33573357
if (!is_submodule_active(the_repository, add_data->sm_path)) {
33583358
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");
33603360
free(key);
33613361
}
33623362
} else {
33633363
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");
33653365
free(key);
33663366
}
33673367
}

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 int git_config_set_gently(const char *key, const char *value)
738-
{
739-
return repo_config_set_gently(the_repository, key, value);
740-
}
741-
742737
static inline void git_config_set(const char *key, const char *value)
743738
{
744739
repo_config_set(the_repository, key, value);

scalar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static int set_scalar_config(const struct scalar_config *config, int reconfigure
103103
if ((reconfigure && config->overwrite_on_reconfigure) ||
104104
repo_config_get_string(the_repository, config->key, &value)) {
105105
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);
107107
} else {
108108
trace2_data_string("scalar", the_repository, config->key, "exists");
109109
res = 0;
@@ -322,7 +322,7 @@ static int set_config(const char *fmt, ...)
322322
value = strchr(buf.buf, '=');
323323
if (value)
324324
*(value++) = '\0';
325-
res = git_config_set_gently(buf.buf, value);
325+
res = repo_config_set_gently(the_repository, buf.buf, value);
326326
strbuf_release(&buf);
327327

328328
return res;

setup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,13 +2236,13 @@ void initialize_repository_version(int hash_algo,
22362236
git_config_set("extensions.objectformat",
22372237
hash_algos[hash_algo].name);
22382238
else if (reinit)
2239-
git_config_set_gently("extensions.objectformat", NULL);
2239+
repo_config_set_gently(the_repository, "extensions.objectformat", NULL);
22402240

22412241
if (ref_storage_format != REF_STORAGE_FORMAT_FILES)
22422242
git_config_set("extensions.refstorage",
22432243
ref_storage_format_to_name(ref_storage_format));
22442244
else if (reinit)
2245-
git_config_set_gently("extensions.refstorage", NULL);
2245+
repo_config_set_gently(the_repository, "extensions.refstorage", NULL);
22462246

22472247
if (reinit) {
22482248
struct strbuf config = STRBUF_INIT;

worktree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ int init_worktree_config(struct repository *r)
10131013
*/
10141014
if (r->repository_format_worktree_config)
10151015
return 0;
1016-
if ((res = git_config_set_gently("extensions.worktreeConfig", "true")))
1016+
if ((res = repo_config_set_gently(the_repository, "extensions.worktreeConfig", "true")))
10171017
return error(_("failed to set extensions.worktreeConfig setting"));
10181018

10191019
common_config_file = xstrfmt("%s/config", r->commondir);
@@ -1077,7 +1077,7 @@ void write_worktree_linking_files(struct strbuf dotgit, struct strbuf gitdir,
10771077
if (use_relative_paths && !the_repository->repository_format_relative_worktrees) {
10781078
if (upgrade_repository_format(1) < 0)
10791079
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"))
10811081
die(_("unable to set extensions.relativeWorktrees setting"));
10821082
the_repository->repository_format_relative_worktrees = 1;
10831083
}

0 commit comments

Comments
 (0)