Skip to content

Commit cba3c02

Browse files
pks-tgitster
authored andcommitted
config: drop git_config_get_string() 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_get_string()`. All callsites are adjusted so that they use `repo_config_get_string(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 627d08c commit cba3c02

File tree

14 files changed

+19
-24
lines changed

14 files changed

+19
-24
lines changed

builtin/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2508,7 +2508,7 @@ int cmd_fetch(int argc,
25082508
if (!max_jobs)
25092509
max_jobs = online_cpus();
25102510

2511-
if (!git_config_get_string_tmp("fetch.bundleuri", &bundle_uri) &&
2511+
if (!repo_config_get_string_tmp(the_repository, "fetch.bundleuri", &bundle_uri) &&
25122512
fetch_bundle_uri(the_repository, bundle_uri, NULL))
25132513
warning(_("failed to fetch bundles from '%s'"), bundle_uri);
25142514

builtin/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ static void initialize_task_config(struct maintenance_run_opts *opts,
17651765
if (opts->schedule) {
17661766
strategy = none_strategy;
17671767

1768-
if (!git_config_get_string_tmp("maintenance.strategy", &config_str)) {
1768+
if (!repo_config_get_string_tmp(the_repository, "maintenance.strategy", &config_str)) {
17691769
if (!strcasecmp(config_str, "incremental"))
17701770
strategy = incremental_strategy;
17711771
}
@@ -1788,7 +1788,7 @@ static void initialize_task_config(struct maintenance_run_opts *opts,
17881788
strbuf_reset(&config_name);
17891789
strbuf_addf(&config_name, "maintenance.%s.schedule",
17901790
tasks[i].name);
1791-
if (!git_config_get_string_tmp(config_name.buf, &config_str))
1791+
if (!repo_config_get_string_tmp(the_repository, config_name.buf, &config_str))
17921792
strategy.tasks[i].schedule = parse_schedule(config_str);
17931793
if (strategy.tasks[i].schedule < opts->schedule)
17941794
continue;

builtin/remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ static int get_one_entry(struct remote *remote, void *priv)
12681268

12691269
strbuf_addf(&promisor_config, "remote.%s.partialclonefilter", remote->name);
12701270
strbuf_addf(&remote_info_buf, "%s (fetch)", remote->url.v[0]);
1271-
if (!git_config_get_string_tmp(promisor_config.buf, &partial_clone_filter))
1271+
if (!repo_config_get_string_tmp(the_repository, promisor_config.buf, &partial_clone_filter))
12721272
strbuf_addf(&remote_info_buf, " [%s]", partial_clone_filter);
12731273

12741274
strbuf_release(&promisor_config);

builtin/submodule--helper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ static void init_submodule(const char *path, const char *prefix,
496496

497497
/* Copy "update" setting when it is not set yet */
498498
strbuf_addf(&sb, "submodule.%s.update", sub->name);
499-
if (git_config_get_string_tmp(sb.buf, &upd) &&
499+
if (repo_config_get_string_tmp(the_repository, sb.buf, &upd) &&
500500
sub->update_strategy.type != SM_UPDATE_UNSPECIFIED) {
501501
if (sub->update_strategy.type == SM_UPDATE_COMMAND) {
502502
fprintf(stderr, _("warning: command update mode suggested for submodule '%s'\n"),
@@ -1034,7 +1034,7 @@ static void prepare_submodule_summary(struct summary_cb *info,
10341034

10351035
config_key = xstrfmt("submodule.%s.ignore",
10361036
sub->name);
1037-
if (!git_config_get_string_tmp(config_key, &value))
1037+
if (!repo_config_get_string_tmp(the_repository, config_key, &value))
10381038
ignore_all = !strcmp(value, "all");
10391039
else if (sub->ignore)
10401040
ignore_all = !strcmp(sub->ignore, "all");

checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ char *unique_tracking_name(const char *name, struct object_id *oid,
5252
{
5353
struct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT;
5454
const char *default_remote = NULL;
55-
if (!git_config_get_string_tmp("checkout.defaultremote", &default_remote))
55+
if (!repo_config_get_string_tmp(the_repository, "checkout.defaultremote", &default_remote))
5656
cb_data.default_remote = default_remote;
5757
cb_data.src_ref = xstrfmt("refs/heads/%s", name);
5858
cb_data.dst_oid = oid;

config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,11 +719,6 @@ NORETURN void git_die_config_linenr(const char *key, const char *filename, int l
719719
int lookup_config(const char **mapping, int nr_mapping, const char *var);
720720

721721
# ifdef USE_THE_REPOSITORY_VARIABLE
722-
static inline int git_config_get_string_tmp(const char *key, const char **dest)
723-
{
724-
return repo_config_get_string_tmp(the_repository, key, dest);
725-
}
726-
727722
static inline int git_config_get_int(const char *key, int *dest)
728723
{
729724
return repo_config_get_int(the_repository, key, dest);

connect.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ static const char *get_ssh_command(void)
11541154
if ((ssh = getenv("GIT_SSH_COMMAND")))
11551155
return ssh;
11561156

1157-
if (!git_config_get_string_tmp("core.sshcommand", &ssh))
1157+
if (!repo_config_get_string_tmp(the_repository, "core.sshcommand", &ssh))
11581158
return ssh;
11591159

11601160
return NULL;
@@ -1173,7 +1173,7 @@ static void override_ssh_variant(enum ssh_variant *ssh_variant)
11731173
{
11741174
const char *variant = getenv("GIT_SSH_VARIANT");
11751175

1176-
if (!variant && git_config_get_string_tmp("ssh.variant", &variant))
1176+
if (!variant && repo_config_get_string_tmp(the_repository, "ssh.variant", &variant))
11771177
return;
11781178

11791179
if (!strcmp(variant, "auto"))

editor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const char *git_sequence_editor(void)
5050
const char *editor = getenv("GIT_SEQUENCE_EDITOR");
5151

5252
if (!editor)
53-
git_config_get_string_tmp("sequence.editor", &editor);
53+
repo_config_get_string_tmp(the_repository, "sequence.editor", &editor);
5454
if (!editor)
5555
editor = git_editor();
5656

help.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ void list_cmds_by_config(struct string_list *list)
417417
{
418418
const char *cmd_list;
419419

420-
if (git_config_get_string_tmp("completion.commands", &cmd_list))
420+
if (repo_config_get_string_tmp(the_repository, "completion.commands", &cmd_list))
421421
return;
422422

423423
string_list_sort(list);

promisor-remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static void promisor_info_vecs(struct repository *repo,
327327
char *url_key = xstrfmt("remote.%s.url", r->name);
328328

329329
/* Only add remotes with a non empty URL */
330-
if (!git_config_get_string_tmp(url_key, &url) && *url) {
330+
if (!repo_config_get_string_tmp(the_repository, url_key, &url) && *url) {
331331
strvec_push(names, r->name);
332332
strvec_push(urls, url);
333333
}
@@ -433,7 +433,7 @@ static void filter_promisor_remote(struct repository *repo,
433433
struct strvec names = STRVEC_INIT;
434434
struct strvec urls = STRVEC_INIT;
435435

436-
if (!git_config_get_string_tmp("promisor.acceptfromserver", &accept_str)) {
436+
if (!repo_config_get_string_tmp(the_repository, "promisor.acceptfromserver", &accept_str)) {
437437
if (!*accept_str || !strcasecmp("None", accept_str))
438438
accept = ACCEPT_NONE;
439439
else if (!strcasecmp("KnownUrl", accept_str))

0 commit comments

Comments
 (0)