diff mbox series

[v5,4/8] remote-odb: add remote_odb_reinit()

Message ID 20180925115341.19248-5-chriscool@tuxfamily.org (mailing list archive)
State New, archived
Headers show
Series Introducing remote ODBs | expand

Commit Message

Christian Couder Sept. 25, 2018, 11:53 a.m. UTC
From: Christian Couder <christian.couder@gmail.com>

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

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 remote-odb.c | 14 ++++++++++++--
 remote-odb.h |  1 +
 2 files changed, 13 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/remote-odb.c b/remote-odb.c
index 53900203ae..cd1b393b79 100644
--- a/remote-odb.c
+++ b/remote-odb.c
@@ -64,17 +64,27 @@  static int remote_odb_config(const char *var, const char *value, void *data)
 	return 0;
 }
 
-static void remote_odb_init(void)
+static void remote_odb_do_init(int force)
 {
 	static int initialized;
 
-	if (initialized)
+	if (!force && initialized)
 		return;
 	initialized = 1;
 
 	git_config(remote_odb_config, NULL);
 }
 
+static inline void remote_odb_init(void)
+{
+	remote_odb_do_init(0);
+}
+
+void remote_odb_reinit(void)
+{
+	remote_odb_do_init(1);
+}
+
 struct odb_helper *find_odb_helper(const char *remote)
 {
 	remote_odb_init();
diff --git a/remote-odb.h b/remote-odb.h
index 221305d1b6..0d1170cf41 100644
--- a/remote-odb.h
+++ b/remote-odb.h
@@ -1,6 +1,7 @@ 
 #ifndef REMOTE_ODB_H
 #define REMOTE_ODB_H
 
+extern void remote_odb_reinit(void);
 extern struct odb_helper *find_odb_helper(const char *remote);
 extern int has_remote_odb(void);
 extern int remote_odb_get_direct(const struct object_id *oids, int oid_nr);