promisor-remote: add promisor_remote_reinit()

We will need to reinitialize the promisor remote configuration as we will make some changes to it in a later commit. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Jun 25, 2019 at 15:40 UTC 9cfebc1f3b2b60290b6321b95e5038b6e5b758ab
2 files changed +21 -2
promisor-remote.c
+20 -2
@@ -67,10 +67,10 @@ static int promisor_remote_config(const char *var, const char *value, void *data
67 return 0;
68 }
69
70 +static int initialized;
71 +
72 static void promisor_remote_init(void)
73 {
72 - static int initialized;
73 -
74 if (initialized)
75 return;
76 initialized = 1;
@@ -78,6 +78,24 @@ static void promisor_remote_init(void)
78 git_config(promisor_remote_config, NULL);
79 }
80
81 +static void promisor_remote_clear(void)
82 +{
83 + while (promisors) {
84 + struct promisor_remote *r = promisors;
85 + promisors = promisors->next;
86 + free(r);
87 + }
88 +
89 + promisors_tail = &promisors;
90 +}
91 +
92 +void promisor_remote_reinit(void)
93 +{
94 + initialized = 0;
95 + promisor_remote_clear();
96 + promisor_remote_init();
97 +}
98 +
99 struct promisor_remote *promisor_remote_find(const char *remote_name)
100 {
101 promisor_remote_init();
promisor-remote.h
+1
@@ -12,6 +12,7 @@ struct promisor_remote {
12 const char name[FLEX_ARRAY];
13 };
14
15 +extern void promisor_remote_reinit(void);
16 extern struct promisor_remote *promisor_remote_find(const char *remote_name);
17 extern int has_promisor_remote(void);
18 extern int promisor_remote_get_direct(struct repository *repo,