Message ID | 20190312132959.11764-5-chriscool@tuxfamily.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Many promisor remotes | expand |
Christian Couder <christian.couder@gmail.com> writes: > From: Christian Couder <christian.couder@gmail.com> > > 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> > --- At this point, turning "initialized" into a file-scope static, and building reinit as void promisor_remote_reinit(void) { initialized = 0; ... clear existing "promisor" entries ... promisor_remote_init(); } may make more sense. > -static void promisor_remote_init(void) > +static void promisor_remote_do_init(int force) > { > static int initialized; > > - if (initialized) > + if (!force && initialized) > return; > initialized = 1; > > git_config(promisor_remote_config, NULL); The promisors and promisors_tail would need to be reinitiazlied and existing elements on the list purged. Otherwise, after removing an entry from the configuration file, the entry will still stay around. > } > > +static inline void promisor_remote_init(void) > +{ > + promisor_remote_do_init(0); > +} > + > +void promisor_remote_reinit(void) > +{ > + promisor_remote_do_init(1); > +} > + > struct promisor_remote *promisor_remote_find(const char *remote_name) > { > promisor_remote_init(); > diff --git a/promisor-remote.h b/promisor-remote.h > index f9f5825417..f96722bc66 100644 > --- a/promisor-remote.h > +++ b/promisor-remote.h > @@ -10,6 +10,7 @@ struct promisor_remote { > struct promisor_remote *next; > }; > > +extern void promisor_remote_reinit(void); > extern struct promisor_remote *promisor_remote_new(const char *remote_name); > extern struct promisor_remote *promisor_remote_find(const char *remote_name); > extern int has_promisor_remote(void);
On Wed, Mar 13, 2019 at 5:28 AM Junio C Hamano <gitster@pobox.com> wrote: > > Christian Couder <christian.couder@gmail.com> writes: > > > From: Christian Couder <christian.couder@gmail.com> > > > > 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> > > --- > > At this point, turning "initialized" into a file-scope static, and > building reinit as > > void promisor_remote_reinit(void) > { > initialized = 0; > ... clear existing "promisor" entries ... > promisor_remote_init(); > } > > may make more sense. Ok, I implemented that. > > -static void promisor_remote_init(void) > > +static void promisor_remote_do_init(int force) > > { > > static int initialized; > > > > - if (initialized) > > + if (!force && initialized) > > return; > > initialized = 1; > > > > git_config(promisor_remote_config, NULL); > > The promisors and promisors_tail would need to be reinitiazlied and > existing elements on the list purged. Otherwise, after removing an > entry from the configuration file, the entry will still stay around. Yeah, that's in the new version too. > > }
diff --git a/promisor-remote.c b/promisor-remote.c index f86f9d0b84..ea74f6d8a8 100644 --- a/promisor-remote.c +++ b/promisor-remote.c @@ -74,17 +74,27 @@ static int promisor_remote_config(const char *var, const char *value, void *data return 0; } -static void promisor_remote_init(void) +static void promisor_remote_do_init(int force) { static int initialized; - if (initialized) + if (!force && initialized) return; initialized = 1; git_config(promisor_remote_config, NULL); } +static inline void promisor_remote_init(void) +{ + promisor_remote_do_init(0); +} + +void promisor_remote_reinit(void) +{ + promisor_remote_do_init(1); +} + struct promisor_remote *promisor_remote_find(const char *remote_name) { promisor_remote_init(); diff --git a/promisor-remote.h b/promisor-remote.h index f9f5825417..f96722bc66 100644 --- a/promisor-remote.h +++ b/promisor-remote.h @@ -10,6 +10,7 @@ struct promisor_remote { struct promisor_remote *next; }; +extern void promisor_remote_reinit(void); extern struct promisor_remote *promisor_remote_new(const char *remote_name); extern struct promisor_remote *promisor_remote_find(const char *remote_name); extern int has_promisor_remote(void);