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

[PATCH/RFC 7/7] remote-curl: add sparse prefix

From
RRRobin Ruede <r.ruede@gmail.com>
Date
Jul 28, 2016, 16:02 UTC
Message-ID
<20160728160226.24018-8-r.ruede@gmail.com>
In-Reply-To
<20160728160226.24018-1-r.ruede@gmail.com>
Signed-off-by: Robin Ruede <r.ruede@gmail.com>
---
 remote-curl.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/remote-curl.c b/remote-curl.c
index e181e62..b9f7cf1 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -20,6 +20,7 @@ static struct strbuf url = STRBUF_INIT;
 struct options {
 	int verbosity;
 	unsigned long depth;
+	const char *sparse_prefix;
 	unsigned progress : 1,
 		check_self_contained_and_connected : 1,
 		cloning : 1,
@@ -60,6 +61,10 @@ static int set_option(const char *name, const char *value)
 		options.depth = v;
 		return 0;
 	}
+	else if (!strcmp(name, "sparse-prefix")) {
+		options.sparse_prefix = xstrdup(value);
+		return 0;
+	}
 	else if (!strcmp(name, "followtags")) {
 		if (!strcmp(value, "true"))
 			options.followtags = 1;
@@ -754,8 +759,9 @@ static int fetch_git(struct discovery *heads,
 	struct rpc_state rpc;
 	struct strbuf preamble = STRBUF_INIT;
 	char *depth_arg = NULL;
+	char *sparse_arg = NULL;
 	int argc = 0, i, err;
-	const char *argv[17];
+	const char *argv[19];
 
 	argv[argc++] = "fetch-pack";
 	argv[argc++] = "--stateless-rpc";
@@ -783,6 +789,12 @@ static int fetch_git(struct discovery *heads,
 		depth_arg = strbuf_detach(&buf, NULL);
 		argv[argc++] = depth_arg;
 	}
+	if (options.sparse_prefix) {
+		struct strbuf buf = STRBUF_INIT;
+		strbuf_addf(&buf, "--sparse-prefix=%s", options.sparse_prefix);
+		sparse_arg = strbuf_detach(&buf, NULL);
+		argv[argc++] = sparse_arg;
+	}
 	argv[argc++] = url.buf;
 	argv[argc++] = NULL;
 
@@ -807,6 +819,7 @@ static int fetch_git(struct discovery *heads,
 	strbuf_release(&rpc.result);
 	strbuf_release(&preamble);
 	free(depth_arg);
+	free(sparse_arg);
 	return err;
 }
 
-- 
2.9.1.283.g3ca5b4c.dirty
Previous: Robin RuedeNext: Duy Nguyen
Message 8 of 12 in “Add possibility to clone specific subdirectories”
  1. 0/7 Add possibility to clone specific subdirectoriesRobin Ruede, Jul 28, 2016
  2. 1/7 list-objects: add sparse-prefix option to rev_infoRobin Ruede, Jul 28, 2016
  3. 2/7 pack-objects: add sparse-prefixRobin Ruede, Jul 28, 2016
  4. 3/7 Skip checking integrity of files ignored by sparseRobin Ruede, Jul 28, 2016
  5. 5/7 fetch: add sparse-prefix optionRobin Ruede, Jul 28, 2016
  6. 6/7 clone: add sparse-prefix optionRobin Ruede, Jul 28, 2016
  7. 4/7 fetch-pack: add sparse prefix to smart protocolRobin Ruede, Jul 28, 2016
  8. 7/7 remote-curl: add sparse prefixRobin Ruede, Jul 28, 2016
  9. Duy NguyenJul 28, 2016
  10. Duy NguyenJul 28, 2016
  11. Junio C HamanoJul 28, 2016
  12. Duy NguyenJul 29, 2016

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.