From: Christian Couder <christian.cou...@gmail.com>

This function will be used to get many objects from a promisor
remote.

Signed-off-by: Christian Couder <chrisc...@tuxfamily.org>
Signed-off-by: Junio C Hamano <gits...@pobox.com>
---
 odb-helper.c | 15 +++++++++++++++
 odb-helper.h |  3 +++
 remote-odb.c | 17 +++++++++++++++++
 remote-odb.h |  1 +
 4 files changed, 36 insertions(+)

diff --git a/odb-helper.c b/odb-helper.c
index 99b5a345e8..246ebf8f7a 100644
--- a/odb-helper.c
+++ b/odb-helper.c
@@ -28,3 +28,18 @@ int odb_helper_get_direct(struct odb_helper *o,
 
        return res;
 }
+
+int odb_helper_get_many_direct(struct odb_helper *o,
+                              const struct oid_array *to_get)
+{
+       int res;
+       uint64_t start;
+
+       start = getnanotime();
+
+       res = fetch_objects(o->remote, to_get);
+
+       trace_performance_since(start, "odb_helper_get_many_direct");
+
+       return res;
+}
diff --git a/odb-helper.h b/odb-helper.h
index 4c52e81ce8..154ce4c7e4 100644
--- a/odb-helper.h
+++ b/odb-helper.h
@@ -17,4 +17,7 @@ struct odb_helper {
 extern struct odb_helper *odb_helper_new(const char *name, int namelen);
 extern int odb_helper_get_direct(struct odb_helper *o,
                                 const unsigned char *sha1);
+extern int odb_helper_get_many_direct(struct odb_helper *o,
+                                     const struct oid_array *to_get);
+
 #endif /* ODB_HELPER_H */
diff --git a/remote-odb.c b/remote-odb.c
index 7f815c7ebb..09dfc2e16f 100644
--- a/remote-odb.c
+++ b/remote-odb.c
@@ -106,3 +106,20 @@ int remote_odb_get_direct(const unsigned char *sha1)
 
        return -1;
 }
+
+int remote_odb_get_many_direct(const struct oid_array *to_get)
+{
+       struct odb_helper *o;
+
+       trace_printf("trace: remote_odb_get_many_direct: nr: %d", to_get->nr);
+
+       remote_odb_init();
+
+       for (o = helpers; o; o = o->next) {
+               if (odb_helper_get_many_direct(o, to_get) < 0)
+                       continue;
+               return 0;
+       }
+
+       return -1;
+}
diff --git a/remote-odb.h b/remote-odb.h
index c5384c922d..e10a8bf855 100644
--- a/remote-odb.h
+++ b/remote-odb.h
@@ -4,5 +4,6 @@
 extern struct odb_helper *find_odb_helper(const char *remote);
 extern int has_remote_odb(void);
 extern int remote_odb_get_direct(const unsigned char *sha1);
+extern int remote_odb_get_many_direct(const struct oid_array *to_get);
 
 #endif /* REMOTE_ODB_H */
-- 
2.18.0.171.ge260395bfe

Reply via email to