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

[PATCH 2/2] fetch-pack: support --subtree and --commit-subtree options

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jul 26, 2010, 23:36 UTC
Message-ID
<1280187370-23675-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1280187370-23675-1-git-send-email-pclouds@gmail.com>
These options are simply turned to upload-pack's "subtree" and "commit-tree" requests, respectively.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fetch-pack.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index dbd8b7b..0bc7f6d 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -14,6 +14,8 @@ static int transfer_unpack_limit = -1;
 static int fetch_unpack_limit = -1;
 static int unpack_limit = 100;
 static int prefer_ofs_delta = 1;
+static const char *subtree;
+static int commit_subtree;
 static struct fetch_pack_args args = {
 	/* .uploadpack = */ "git-upload-pack",
 };
@@ -237,6 +239,8 @@ static int find_common(int fd[2], unsigned char *result_sha1,
 	for_each_ref(rev_list_insert_ref, NULL);
 
 	fetching = 0;
+	if (subtree)
+		packet_buf_write(&req_buf, "%s %s\n", commit_subtree ? "commit-subtree" : "subtree", subtree);
 	for ( ; refs ; refs = refs->next) {
 		unsigned char *remote = refs->old_sha1;
 		const char *remote_hex;
@@ -692,6 +696,8 @@ static struct ref *do_fetch_pack(int fd[2],
 
 	if (is_repository_shallow() && !server_supports("shallow"))
 		die("Server does not support shallow clients");
+	if (subtree && !server_supports("subtree"))
+		die("Server does not support subtree");
 	if (server_supports("multi_ack_detailed")) {
 		if (args.verbose)
 			fprintf(stderr, "Server supports multi_ack_detailed\n");
@@ -860,6 +866,15 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
 				pack_lockfile_ptr = &pack_lockfile;
 				continue;
 			}
+			if (!prefixcmp(arg, "--subtree=")) {
+				subtree = arg + 10;
+				continue;
+			}
+			if (!prefixcmp(arg, "--commit-subtree=")) {
+				subtree = arg + 17;
+				commit_subtree = 1;
+				continue;
+			}
 			usage(fetch_pack_usage);
 		}
 		dest = (char *)arg;
-- 
1.7.1.rc1.69.g24c2f7
Previous: Nguyen Thai Ngoc Duy
Message 10 of 10 in “Subtree clone?”
  1. 0/2 Subtree clone?Nguyễn Thái Ngọc Duy, Jul 26, 2010
  2. 1/2 upload-pack: support subtree packingNguyễn Thái Ngọc Duy, Jul 26, 2010
  3. Ævar Arnfjörð BjarmasonJul 27, 2010
  4. Shawn O. PearceJul 27, 2010
  5. Configurable callbacks for missing objects (we Re: upload-pack: support subtree packing)Avery Pennarun, Jul 27, 2010
  6. Nguyen Thai Ngoc DuyJul 27, 2010
  7. Elijah NewrenJul 28, 2010
  8. Avery PennarunJul 28, 2010
  9. Nguyen Thai Ngoc DuyJul 27, 2010
  10. 2/2 fetch-pack: support --subtree and --commit-subtree optionsNguyễn Thái Ngọc Duy, Jul 26, 2010

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.