let the GIT native protocol use offsets to delta base when possible
There is no reason not to always do this when both ends agree. Therefore a client that can accept offsets to delta base always sends the "ofs-delta" flag. The server will stream a pack with or without offset to delta base depending on whether that flag is provided or not with no additional cost. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Nicolas Pitre committed
Sep 26, 2006 at 11:27 UTC
e4fe4b8ef7cdde842a9e5e2594d0fba1367d9dd3
2 files changed
+10
-5
fetch-pack.c
+3
-2
@@ -166,12 +166,13 @@ static int find_common(int fd[2], unsigned char *result_sha1,
166
}
167
168
if (!fetching)
169
- packet_write(fd[1], "want %s%s%s%s%s\n",
169
+ packet_write(fd[1], "want %s%s%s%s%s%s\n",
170
sha1_to_hex(remote),
171
(multi_ack ? " multi_ack" : ""),
172
(use_sideband == 2 ? " side-band-64k" : ""),
173
(use_sideband == 1 ? " side-band" : ""),
174
- (use_thin_pack ? " thin-pack" : ""));
174
+ (use_thin_pack ? " thin-pack" : ""),
175
+ " ofs-delta");
176
else
177
packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
178
fetching++;
upload-pack.c
+7
-3
@@ -16,7 +16,7 @@ static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=n
16
#define OUR_REF (1U << 1)
17
#define WANTED (1U << 2)
18
static int multi_ack, nr_our_refs;
19
-static int use_thin_pack;
19
+static int use_thin_pack, use_ofs_delta;
20
static struct object_array have_obj;
21
static struct object_array want_obj;
22
static unsigned int timeout;
@@ -137,7 +137,9 @@ static void create_pack_file(void)
137
close(pu_pipe[1]);
138
close(pe_pipe[0]);
139
close(pe_pipe[1]);
140
- execl_git_cmd("pack-objects", "--stdout", "--progress", NULL);
140
+ execl_git_cmd("pack-objects", "--stdout", "--progress",
141
+ use_ofs_delta ? "--delta-base-offset" : NULL,
142
+ NULL);
143
kill(pid_rev_list, SIGKILL);
144
die("git-upload-pack: unable to exec git-pack-objects");
145
}
@@ -393,6 +395,8 @@ static void receive_needs(void)
395
multi_ack = 1;
396
if (strstr(line+45, "thin-pack"))
397
use_thin_pack = 1;
398
+ if (strstr(line+45, "ofs-delta"))
399
+ use_ofs_delta = 1;
400
if (strstr(line+45, "side-band-64k"))
401
use_sideband = LARGE_PACKET_MAX;
402
else if (strstr(line+45, "side-band"))
@@ -418,7 +422,7 @@ static void receive_needs(void)
422
423
static int send_ref(const char *refname, const unsigned char *sha1)
424
{
421
- static const char *capabilities = "multi_ack thin-pack side-band side-band-64k";
425
+ static const char *capabilities = "multi_ack thin-pack side-band side-band-64k ofs-delta";
426
struct object *o = parse_object(sha1);
427
428
if (!o)