Thread (61 messages) 61 messages, 3 authors, 2017-09-15
STALE3301d

Revision v4 of 3 in this series.

Revisions (3)
  1. v4 current
  2. v5 [diff vs current]
  3. v6 [diff vs current]

[RFC/PATCH v4 33/49] odb-helper: call odb_helper_lookup() with 'have' capability

From: Christian Couder <hidden>
Date: 2017-06-20 07:56:46
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Christian Couder <redacted>
---
 odb-helper.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/odb-helper.c b/odb-helper.c
index a6bf81af8d..910c87a482 100644
--- a/odb-helper.c
+++ b/odb-helper.c
@@ -142,19 +142,20 @@ static int check_object_process_error(int err,
 	return err;
 }
 
-static int read_object_process(const unsigned char *sha1)
+static int read_object_process(struct odb_helper *o, const unsigned char *sha1, int fd)
 {
 	int err;
 	struct read_object_process *entry;
 	struct child_process *process;
 	struct strbuf status = STRBUF_INIT;
-	const char *cmd = "read-object";
+	const char *cmd = o->cmd;
 	uint64_t start;
 
 	start = getnanotime();
 
 	entry = launch_read_object_process(cmd);
 	process = &entry->subprocess.process;
+	o->supported_capabilities = entry->supported_capabilities;
 
 	if (!(ODB_HELPER_CAP_GET & entry->supported_capabilities))
 		return -1;
@@ -173,6 +174,13 @@ static int read_object_process(const unsigned char *sha1)
 	if (err)
 		goto done;
 
+	if (o->fetch_kind != ODB_FETCH_KIND_FAULT_IN) {
+		struct strbuf buf;
+		read_packetized_to_strbuf(process->out, &buf);
+		if (err)
+			goto done;
+	}
+
 	subprocess_read_status(process->out, &status);
 	err = strcmp(status.buf, "success");
 
@@ -554,10 +562,11 @@ static int odb_helper_fetch_git_object(struct odb_helper *o,
 int odb_helper_fault_in_object(struct odb_helper *o,
 			       const unsigned char *sha1)
 {
-	struct odb_helper_object *obj = odb_helper_lookup(o, sha1);
-
-	if (!obj)
-		return -1;
+	if (o->supported_capabilities & ODB_HELPER_CAP_HAVE) {
+		struct odb_helper_object *obj = odb_helper_lookup(o, sha1);
+		if (!obj)
+			return -1;
+	}
 
 	if (o->script_mode) {
 		struct odb_helper_cmd cmd;
@@ -567,7 +576,7 @@ int odb_helper_fault_in_object(struct odb_helper *o,
 			return -1;
 		return 0;
 	} else {
-		return read_object_process(sha1);
+		return read_object_process(o, sha1, -1);
 	}
 }
 
-- 
2.13.1.565.gbfcd7a9048
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help