Web lists-archives.com

[PATCH v1 5/8] odb-remote: add odb_remote_reinit()




We will need to reinitialize the odb remote configuration
as we will make some changes to it in a later commit when
we will detect that a remote is also an odb remote.

Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
---
 odb-remote.c | 14 ++++++++++++--
 odb-remote.h |  1 +
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/odb-remote.c b/odb-remote.c
index 9a1561430c..0a734ff379 100644
--- a/odb-remote.c
+++ b/odb-remote.c
@@ -39,17 +39,27 @@ static int odb_remote_config(const char *var, const char *value, void *data)
 	return 0;
 }
 
-static void odb_remote_init(void)
+static void odb_remote_do_init(int force)
 {
 	static int initialized;
 
-	if (initialized)
+	if (!force && initialized)
 		return;
 	initialized = 1;
 
 	git_config(odb_remote_config, NULL);
 }
 
+static inline void odb_remote_init(void)
+{
+	odb_remote_do_init(0);
+}
+
+inline void odb_remote_reinit(void)
+{
+	odb_remote_do_init(1);
+}
+
 struct odb_helper *find_odb_helper(const char *dealer)
 {
 	struct odb_helper *o;
diff --git a/odb-remote.h b/odb-remote.h
index e6cedde722..d862216a8f 100644
--- a/odb-remote.h
+++ b/odb-remote.h
@@ -1,6 +1,7 @@
 #ifndef ODB_REMOTE_H
 #define ODB_REMOTE_H
 
+extern void odb_remote_reinit(void);
 extern struct odb_helper *find_odb_helper(const char *dealer);
 extern int has_odb_remote(void);
 extern int odb_remote_get_direct(const unsigned char *sha1);
-- 
2.17.0.590.gbd05bfcafd