git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1 3/8] promisor-remote: implement promisors_get_direct()

From
Christian Couder <christian.couder@gmail.com>
Date
Dec 11, 2018, 05:27 UTC
Message-ID
<20181211052746.16218-4-chriscool@tuxfamily.org>
In-Reply-To
<20181211052746.16218-1-chriscool@tuxfamily.org>
From: Christian Couder <christian.couder@gmail.com>

This is implemented for now by calling fetch_objects(). It fetches from all the promisor remotes.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 promisor-remote.c | 33 +++++++++++++++++++++++++++++++++
 promisor-remote.h |  1 +
 2 files changed, 34 insertions(+)
diff --git a/promisor-remote.c b/promisor-remote.c
index 701f5a351b..e0724bdc20 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "promisor-remote.h"
 #include "config.h"
+#include "fetch-object.h"
 
 static struct promisor_remote *promisors;
 static struct promisor_remote **promisors_tail = &promisors;
@@ -88,3 +89,35 @@ int has_promisor_remote(void)
 {
 	return !!find_promisor_remote(NULL);
 }
+
+static int promisor_remote_get_direct(struct promisor_remote *o,
+				      const struct object_id *oids,
+				      int oid_nr)
+{
+	int res;
+	uint64_t start = getnanotime();
+
+	res = fetch_objects(o->remote_name, oids, oid_nr);
+
+	trace_performance_since(start, "promisor_remote_get_direct");
+
+	return res;
+}
+
+int promisors_get_direct(const struct object_id *oids, int oid_nr)
+{
+	struct promisor_remote *o;
+
+	trace_printf("trace: promisor_remote_get_direct: nr: %d", oid_nr);
+
+	promisor_remote_init();
+
+	for (o = promisors; o; o = o->next) {
+		if (promisor_remote_get_direct(o, oids, oid_nr) < 0)
+			continue;
+		return 0;
+	}
+
+	return -1;
+}
+
diff --git a/promisor-remote.h b/promisor-remote.h
index d07ac07a43..8b89221b33 100644
--- a/promisor-remote.h
+++ b/promisor-remote.h
@@ -13,5 +13,6 @@ struct promisor_remote {
 extern struct promisor_remote *promisor_remote_new(const char *remote_name);
 extern struct promisor_remote *find_promisor_remote(const char *remote_name);
 extern int has_promisor_remote(void);
+extern int promisors_get_direct(const struct object_id *oids, int oid_nr);
 
 #endif /* PROMISOR_REMOTE_H */
-- 
2.20.0.rc2.14.g1379de12fa.dirty
Previous: Christian CouderNext: Christian Couder
Message 3 of 9 in “Many promisor remotes”
  1. 0/8 Many promisor remotesChristian Couder, Dec 11, 2018
  2. 1/8 fetch-object: make functions return an error codeChristian Couder, Dec 11, 2018
  3. 3/8 promisor-remote: implement promisors_get_direct()Christian Couder, Dec 11, 2018
  4. 4/8 promisor-remote: add promisor_remote_reinit()Christian Couder, Dec 11, 2018
  5. 5/8 promisor-remote: use repository_format_partial_cloneChristian Couder, Dec 11, 2018
  6. 2/8 Add initial support for many promisor remotesChristian Couder, Dec 11, 2018
  7. 7/8 promisor-remote: parse remote.*.partialclonefilterChristian Couder, Dec 11, 2018
  8. 8/8 t0410: test fetching from many promisor remotesChristian Couder, Dec 11, 2018
  9. 6/8 Use promisors_get_direct() and has_promisor_remote()Christian Couder, Dec 11, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.