Skip to content

Commit 2b472cf

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

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
@@ -79,7 +79,6 @@ static int prefetch = 0;
7979
static int prune = -1; /* unspecified */
8080
#define PRUNE_BY_DEFAULT 0 /* do we prune by default? */
8181

82-
static int fetch_prune_tags_config = -1; /* unspecified */
8382
static int prune_tags = -1; /* unspecified */
8483
#define PRUNE_TAGS_BY_DEFAULT 0 /* do we prune tags by default? */
8584

@@ -108,6 +107,7 @@ static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
108107
struct fetch_config {
109108
enum display_format display_format;
110109
int prune;
110+
int prune_tags;
111111
};
112112

113113
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)
120120
}
121121

122122
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);
124124
return 0;
125125
}
126126

@@ -2057,8 +2057,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
20572057
/* no command line request */
20582058
if (0 <= remote->prune_tags)
20592059
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;
20622062
else
20632063
prune_tags = PRUNE_TAGS_BY_DEFAULT;
20642064
}
@@ -2109,6 +2109,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
21092109
struct fetch_config config = {
21102110
.display_format = DISPLAY_FORMAT_FULL,
21112111
.prune = -1,
2112+
.prune_tags = -1,
21122113
};
21132114
const char *submodule_prefix = "";
21142115
const char *bundle_uri;

0 commit comments

Comments
 (0)