@matheusbsbs / matheus-bagliano / commits / 6523078b96
Fork 0

make shallow repository deepening more network efficient

First of all, I can't find any reason why thin pack generation is explicitly disabled when dealing with a shallow repository. The possible delta base objects are collected from the edge commits which are always obtained through history walking with the same shallow refs as the client, Therefore the client is always going to have those base objects available. So let's remove that restriction. Then we can make shallow repository deepening much more efficient by using the remote's unshallowed commits as edge commits to get preferred base objects for thin pack generation. On git.git, this makes the data transfer for the deepening of a shallow repository from depth 1 to depth 2 around 134 KB instead of 3.68 MB. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Pitre committed Sep 3, 2009 at 19:08 UTC 6523078b96cd39f681e6fa11135049808591fb95
1 file changed +6 -2
upload-pack.c
+6 -2
@@ -31,6 +31,7 @@ static int use_thin_pack, use_ofs_delta, use_include_tag;
31 static int no_progress;
32 static struct object_array have_obj;
33 static struct object_array want_obj;
34 +static struct object_array extra_edge_obj;
35 static unsigned int timeout;
36 /* 0 for no sideband,
37 * otherwise maximum packet size (up to 65520 bytes).
@@ -136,6 +137,10 @@ static int do_rev_list(int fd, void *create_full_pack)
137 if (prepare_revision_walk(&revs))
138 die("revision walk setup failed");
139 mark_edges_uninteresting(revs.commits, &revs, show_edge);
140 + if (use_thin_pack)
141 + for (i = 0; i < extra_edge_obj.nr; i++)
142 + fprintf(pack_pipe, "-%s\n", sha1_to_hex(
143 + extra_edge_obj.objects[i].item->sha1));
144 traverse_commit_list(&revs, show_commit, show_object, NULL);
145 fflush(pack_pipe);
146 fclose(pack_pipe);
@@ -466,7 +471,6 @@ static void receive_needs(void)
471 if (!prefixcmp(line, "shallow ")) {
472 unsigned char sha1[20];
473 struct object *object;
469 - use_thin_pack = 0;
474 if (get_sha1(line + 8, sha1))
475 die("invalid shallow line: %s", line);
476 object = parse_object(sha1);
@@ -478,7 +482,6 @@ static void receive_needs(void)
482 }
483 if (!prefixcmp(line, "deepen ")) {
484 char *end;
481 - use_thin_pack = 0;
485 depth = strtol(line + 7, &end, 0);
486 if (end == line + 7 || depth <= 0)
487 die("Invalid deepen: %s", line);
@@ -556,6 +559,7 @@ static void receive_needs(void)
559 NULL, &want_obj);
560 parents = parents->next;
561 }
562 + add_object_array(object, NULL, &extra_edge_obj);
563 }
564 /* make sure commit traversal conforms to client */
565 register_shallow(object->sha1);