fetch: use `fetch_config` to store "fetch.prune" value
Move the parsed "fetch.prune" config value into the `fetch_config` structure. This reduces our reliance on global variables and further unifies the way we parse the configuration in git-fetch(1). Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 17, 2023 at 13:48 UTC
b779a25e0570d76b9e41dd9203b36629b90094cd
1 file changed
+5
-4
builtin/fetch.c
+5
-4
@@ -73,7 +73,6 @@ struct display_state {
73
int url_len, shown_url;
74
};
75
76
-static int fetch_prune_config = -1; /* unspecified */
76
static int fetch_show_forced_updates = 1;
77
static uint64_t forced_updates_ms = 0;
78
static int prefetch = 0;
@@ -108,6 +107,7 @@ static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
107
108
struct fetch_config {
109
enum display_format display_format;
110
+ int prune;
111
};
112
113
static int git_fetch_config(const char *k, const char *v, void *cb)
@@ -115,7 +115,7 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
115
struct fetch_config *fetch_config = cb;
116
117
if (!strcmp(k, "fetch.prune")) {
118
- fetch_prune_config = git_config_bool(k, v);
118
+ fetch_config->prune = git_config_bool(k, v);
119
return 0;
120
}
121
@@ -2047,8 +2047,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
2047
/* no command line request */
2048
if (0 <= remote->prune)
2049
prune = remote->prune;
2050
- else if (0 <= fetch_prune_config)
2051
- prune = fetch_prune_config;
2050
+ else if (0 <= config->prune)
2051
+ prune = config->prune;
2052
else
2053
prune = PRUNE_BY_DEFAULT;
2054
}
@@ -2108,6 +2108,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2108
{
2109
struct fetch_config config = {
2110
.display_format = DISPLAY_FORMAT_FULL,
2111
+ .prune = -1,
2112
};
2113
const char *submodule_prefix = "";
2114
const char *bundle_uri;