Skip to content

Commit b779a25

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d1adf85 commit b779a25

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

builtin/fetch.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ struct display_state {
7373
int url_len, shown_url;
7474
};
7575

76-
static int fetch_prune_config = -1; /* unspecified */
7776
static int fetch_show_forced_updates = 1;
7877
static uint64_t forced_updates_ms = 0;
7978
static int prefetch = 0;
@@ -108,14 +107,15 @@ static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
108107

109108
struct fetch_config {
110109
enum display_format display_format;
110+
int prune;
111111
};
112112

113113
static int git_fetch_config(const char *k, const char *v, void *cb)
114114
{
115115
struct fetch_config *fetch_config = cb;
116116

117117
if (!strcmp(k, "fetch.prune")) {
118-
fetch_prune_config = git_config_bool(k, v);
118+
fetch_config->prune = git_config_bool(k, v);
119119
return 0;
120120
}
121121

@@ -2047,8 +2047,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
20472047
/* no command line request */
20482048
if (0 <= remote->prune)
20492049
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;
20522052
else
20532053
prune = PRUNE_BY_DEFAULT;
20542054
}
@@ -2108,6 +2108,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
21082108
{
21092109
struct fetch_config config = {
21102110
.display_format = DISPLAY_FORMAT_FULL,
2111+
.prune = -1,
21112112
};
21122113
const char *submodule_prefix = "";
21132114
const char *bundle_uri;

0 commit comments

Comments
 (0)