{"thread":{"id":"5703","subject":"[PATCH 8/6] let the GIT native protocol use offsets to delta base when possible","startedAt":"2006-09-26T15:27:39Z","lastAt":"2006-09-26T15:27:39Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"27682","messageId":"Pine.LNX.4.64.0609261108250.9349@xanadu.home","threadId":"5703","inReplyTo":null,"subject":"[PATCH 8/6] let the GIT native protocol use offsets to delta base when possible","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2006-09-26T15:27:39Z","receivedAt":"2006-09-26T15:27:39Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"There is no reason not to always do this when both ends agree.  \nTherefore a client that can accept offsets to delta base always sends \nthe \"ofs-delta\" flag.  The server will stream a pack with or without \noffset to delta base depending on whether that flag is provided or not \nwith no additional cost.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n\n---\n\nYeah... 8th of 6 should mean this is pretty much over now.\n\nSince this depends on support that has been merged into the pu branch I \ndiffed this against pu.\n\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 99ac08b..90b7940 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -166,12 +166,13 @@ static int find_common(int fd[2], unsign\n \t\t}\n \n \t\tif (!fetching)\n-\t\t\tpacket_write(fd[1], \"want %s%s%s%s%s\\n\",\n+\t\t\tpacket_write(fd[1], \"want %s%s%s%s%s%s\\n\",\n \t\t\t\t     sha1_to_hex(remote),\n \t\t\t\t     (multi_ack ? \" multi_ack\" : \"\"),\n \t\t\t\t     (use_sideband == 2 ? \" side-band-64k\" : \"\"),\n \t\t\t\t     (use_sideband == 1 ? \" side-band\" : \"\"),\n-\t\t\t\t     (use_thin_pack ? \" thin-pack\" : \"\"));\n+\t\t\t\t     (use_thin_pack ? \" thin-pack\" : \"\"),\n+\t\t\t\t     \" ofs-delta\");\n \t\telse\n \t\t\tpacket_write(fd[1], \"want %s\\n\", sha1_to_hex(remote));\n \t\tfetching++;\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 4e53edd..4572fff 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -22,7 +22,7 @@ #define REACHABLE\t(1u << 15)\n static unsigned long oldest_have;\n \n static int multi_ack, nr_our_refs;\n-static int use_thin_pack;\n+static int use_thin_pack, use_ofs_delta;\n static struct object_array have_obj;\n static struct object_array want_obj;\n static unsigned int timeout;\n@@ -143,7 +143,9 @@ static void create_pack_file(void)\n \t\tclose(pu_pipe[1]);\n \t\tclose(pe_pipe[0]);\n \t\tclose(pe_pipe[1]);\n-\t\texecl_git_cmd(\"pack-objects\", \"--stdout\", \"--progress\", NULL);\n+\t\texecl_git_cmd(\"pack-objects\", \"--stdout\", \"--progress\",\n+\t\t\t      use_ofs_delta ? \"--delta-base-offset\" : NULL,\n+\t\t\t      NULL);\n \t\tkill(pid_rev_list, SIGKILL);\n \t\tdie(\"git-upload-pack: unable to exec git-pack-objects\");\n \t}\n@@ -476,6 +478,8 @@ static void receive_needs(void)\n \t\t\tmulti_ack = 1;\n \t\tif (strstr(line+45, \"thin-pack\"))\n \t\t\tuse_thin_pack = 1;\n+\t\tif (strstr(line+45, \"ofs-delta\"))\n+\t\t\tuse_ofs_delta = 1;\n \t\tif (strstr(line+45, \"side-band-64k\"))\n \t\t\tuse_sideband = LARGE_PACKET_MAX;\n \t\telse if (strstr(line+45, \"side-band\"))\n@@ -501,7 +505,7 @@ static void receive_needs(void)\n \n static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)\n {\n-\tstatic const char *capabilities = \"multi_ack thin-pack side-band side-band-64k\";\n+\tstatic const char *capabilities = \"multi_ack thin-pack side-band side-band-64k ofs-delta\";\n \tstruct object *o = parse_object(sha1);\n \n \tif (!o)\n"}]}