promisor-remote: add promisor_remote_reinit()
authorChristian Couder <christian.couder@gmail.com>
Tue, 25 Jun 2019 13:40:29 +0000 (15:40 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Jun 2019 21:05:37 +0000 (14:05 -0700)
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>
promisor-remote.c
promisor-remote.h
index b79a84ce3a5c0f46a0c1bbe82ba96514d18dbd63..763d98aedd85d69fc393b172ccfd8e4d8c0d75dd 100644 (file)
@@ -67,10 +67,10 @@ static int promisor_remote_config(const char *var, const char *value, void *data
        return 0;
 }
 
+static int initialized;
+
 static void promisor_remote_init(void)
 {
-       static int initialized;
-
        if (initialized)
                return;
        initialized = 1;
@@ -78,6 +78,24 @@ static void promisor_remote_init(void)
        git_config(promisor_remote_config, NULL);
 }
 
+static void promisor_remote_clear(void)
+{
+       while (promisors) {
+               struct promisor_remote *r = promisors;
+               promisors = promisors->next;
+               free(r);
+       }
+
+       promisors_tail = &promisors;
+}
+
+void promisor_remote_reinit(void)
+{
+       initialized = 0;
+       promisor_remote_clear();
+       promisor_remote_init();
+}
+
 struct promisor_remote *promisor_remote_find(const char *remote_name)
 {
        promisor_remote_init();
index ed4ecead36f5a37ad65918c4b3fb489eaaa44e14..dddd4048e0cc015df353b1b595c8904215f187fe 100644 (file)
@@ -12,6 +12,7 @@ struct promisor_remote {
        const char name[FLEX_ARRAY];
 };
 
+extern void promisor_remote_reinit(void);
 extern struct promisor_remote *promisor_remote_find(const char *remote_name);
 extern int has_promisor_remote(void);
 extern int promisor_remote_get_direct(struct repository *repo,