[PATCH 07/16] upload-pack: support subtree pack

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?=
Date: Saturday, July 31, 2010 - 9:18 am

With core_subtree turned on (capability "subtree", request "subtree"
from fetch-pack), traverse_commit_list will be in "subtree mode",
which will not go farther than the given subtree.

As the result, the pack is broken be design, only contains enough
blobs/trees/commits to reach the given subtree.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 upload-pack.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/upload-pack.c b/upload-pack.c
index e432e83..9b6710a 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -160,7 +160,7 @@ static void create_pack_file(void)
 	ssize_t sz;
 	const char *argv[10];
 	int arg = 0;
-	int internal_rev_list = shallow_nr;
+	int internal_rev_list = shallow_nr || core_subtree;
 
 	if (internal_rev_list) {
 		memset(&rev_list, 0, sizeof(rev_list));
@@ -505,6 +505,20 @@ static void receive_needs(void)
 		if (debug_fd)
 			write_in_full(debug_fd, line, len);
 
+		if (!prefixcmp(line, "subtree ")) {
+			int len;
+			char *subtree;
+			if (core_subtree)
+				die("sorry, only one subtree supported");
+			len = strlen(line+8);
+			subtree = malloc(len+1);
+			memcpy(subtree, line+8, len-1);
+			subtree[len-1] = '\0'; /* \n */
+			if (subtree[len-2] != '/')
+				die("subtree request must end with a slash");
+			core_subtree = subtree;
+			continue;
+		}
 		if (!prefixcmp(line, "shallow ")) {
 			unsigned char sha1[20];
 			struct object *object;
@@ -624,7 +638,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
 {
 	static const char *capabilities = "multi_ack thin-pack side-band"
 		" side-band-64k ofs-delta shallow no-progress"
-		" include-tag multi_ack_detailed";
+		" include-tag multi_ack_detailed subtree";
 	struct object *o = parse_object(sha1);
 
 	if (!o)
-- 
1.7.1.rc1.69.g24c2f7

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/16] Subtree clone proof of concept, =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 01/16] Add core.subtree, =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 02/16] list-objects: limit traversing within the gi ..., =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 03/16] parse_object: keep sha1 even when parsing re ..., =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 04/16] Allow to invalidate a commit in in-memory ob ..., =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 05/16] Hook up replace-object to allow bulk commit ..., =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 06/16] upload-pack: use a separate variable to cont ..., =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 07/16] upload-pack: support subtree pack, =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 08/16] fetch-pack: support --subtree, =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 09/16] subtree: rewrite incoming commits, =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 10/16] clone: support subtree clone with parameter ..., =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 11/16] pack-objects: add --subtree (for pushing), =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 12/16] subtree: rewriting outgoing commits, =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 13/16] Update commit_tree() interface to take base ..., =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 14/16] commit_tree(): rewriting/replacing new commits, =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 15/16] commit: rewrite outgoing commits, =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
[PATCH 16/16] do not use thin packs and subtree together ( ..., =?UTF-8?q?Nguy=E1=BB ..., (Sat Jul 31, 9:18 am)
Re: [PATCH 00/16] Subtree clone proof of concept, Sverre Rabbelier, (Sat Jul 31, 9:14 pm)
Re: [PATCH 00/16] Subtree clone proof of concept, Nguyen Thai Ngoc Duy, (Sat Jul 31, 11:58 pm)
Re: [PATCH 02/16] list-objects: limit traversing within th ..., Ævar Arnfjörð Bjarmason, (Sun Aug 1, 4:30 am)
Re: [PATCH 00/16] Subtree clone proof of concept, Sverre Rabbelier, (Sun Aug 1, 1:05 pm)
Re: [PATCH 02/16] list-objects: limit traversing within th ..., Nguyen Thai Ngoc Duy, (Sun Aug 1, 4:11 pm)
Re: [PATCH 07/16] upload-pack: support subtree pack, Elijah Newren, (Sun Aug 1, 9:27 pm)
Re: [PATCH 09/16] subtree: rewrite incoming commits, Elijah Newren, (Sun Aug 1, 9:37 pm)
Re: [PATCH 12/16] subtree: rewriting outgoing commits, Elijah Newren, (Sun Aug 1, 9:40 pm)
Re: [PATCH 00/16] Subtree clone proof of concept, Elijah Newren, (Sun Aug 1, 10:18 pm)
Re: [PATCH 02/16] list-objects: limit traversing within th ..., Nguyen Thai Ngoc Duy, (Sun Aug 1, 11:51 pm)
Re: [PATCH 00/16] Subtree clone proof of concept, Nguyen Thai Ngoc Duy, (Mon Aug 2, 12:10 am)
Re: [PATCH 05/16] Hook up replace-object to allow bulk com ..., Nguyen Thai Ngoc Duy, (Mon Aug 2, 3:42 pm)
Re: [PATCH 00/16] Subtree clone proof of concept, Nguyen Thai Ngoc Duy, (Mon Aug 2, 3:55 pm)