fetch: use `fetch_config` to store "fetch.pruneTags" value
Move the parsed "fetch.pruneTags" 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:49 UTC
2b472cfeacbffcabe0d3a358d50d32ce28fdf4a0
1 file changed
+5
-4
builtin/fetch.c
+5
-4
@@ -79,7 +79,6 @@ static int prefetch = 0;
79
static int prune = -1; /* unspecified */
80
#define PRUNE_BY_DEFAULT 0 /* do we prune by default? */
81
82
-static int fetch_prune_tags_config = -1; /* unspecified */
82
static int prune_tags = -1; /* unspecified */
83
#define PRUNE_TAGS_BY_DEFAULT 0 /* do we prune tags by default? */
84
@@ -108,6 +107,7 @@ static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
107
struct fetch_config {
108
enum display_format display_format;
109
int prune;
110
+ int prune_tags;
111
};
112
113
static int git_fetch_config(const char *k, const char *v, void *cb)
@@ -120,7 +120,7 @@ static int git_fetch_config(const char *k, const char *v, void *cb)
120
}
121
122
if (!strcmp(k, "fetch.prunetags")) {
123
- fetch_prune_tags_config = git_config_bool(k, v);
123
+ fetch_config->prune_tags = git_config_bool(k, v);
124
return 0;
125
}
126
@@ -2057,8 +2057,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
2057
/* no command line request */
2058
if (0 <= remote->prune_tags)
2059
prune_tags = remote->prune_tags;
2060
- else if (0 <= fetch_prune_tags_config)
2061
- prune_tags = fetch_prune_tags_config;
2060
+ else if (0 <= config->prune_tags)
2061
+ prune_tags = config->prune_tags;
2062
else
2063
prune_tags = PRUNE_TAGS_BY_DEFAULT;
2064
}
@@ -2109,6 +2109,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
2109
struct fetch_config config = {
2110
.display_format = DISPLAY_FORMAT_FULL,
2111
.prune = -1,
2112
+ .prune_tags = -1,
2113
};
2114
const char *submodule_prefix = "";
2115
const char *bundle_uri;