Skip to content

Commit d03068d

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dcc8b4e commit d03068d

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

promisor-remote.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,35 @@ static int promisor_remote_config(const char *var, const char *value, void *data
6767
return 0;
6868
}
6969

70+
static int initialized;
71+
7072
static void promisor_remote_init(void)
7173
{
72-
static int initialized;
73-
7474
if (initialized)
7575
return;
7676
initialized = 1;
7777

7878
git_config(promisor_remote_config, NULL);
7979
}
8080

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+
8199
struct promisor_remote *promisor_remote_find(const char *remote_name)
82100
{
83101
promisor_remote_init();

promisor-remote.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct promisor_remote {
1212
const char name[FLEX_ARRAY];
1313
};
1414

15+
extern void promisor_remote_reinit(void);
1516
extern struct promisor_remote *promisor_remote_find(const char *remote_name);
1617
extern int has_promisor_remote(void);
1718
extern int promisor_remote_get_direct(const struct object_id *oids, int oid_nr);

0 commit comments

Comments
 (0)