@matheusbsbs / matheus-bagliano / commits / f04833ef9f
Fork 0

honor repack.usedeltabaseoffset when fetching packs

If the local receiving repository has disabled the use of delta base offset, for example to retain compatibility with older versions of Git that predate OFS_DELTA, we shouldn't ask for ofs-delta support when we obtain a pack from the remote server. [ issue noticed by Shawn Pearce ] Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nicolas Pitre committed May 1, 2009 at 20:18 UTC f04833ef9f330612a4116401258882b38e95744e
1 file changed +12 -1
builtin-fetch-pack.c
+12 -1
@@ -13,6 +13,7 @@
13 static int transfer_unpack_limit = -1;
14 static int fetch_unpack_limit = -1;
15 static int unpack_limit = 100;
16 +static int prefer_ofs_delta = 1;
17 static struct fetch_pack_args args = {
18 /* .uploadpack = */ "git-upload-pack",
19 };
@@ -200,7 +201,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
201 (args.use_thin_pack ? " thin-pack" : ""),
202 (args.no_progress ? " no-progress" : ""),
203 (args.include_tag ? " include-tag" : ""),
203 - " ofs-delta");
204 + (prefer_ofs_delta ? " ofs-delta" : ""));
205 else
206 packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
207 fetching++;
@@ -597,6 +598,11 @@ static struct ref *do_fetch_pack(int fd[2],
598 fprintf(stderr, "Server supports side-band\n");
599 use_sideband = 1;
600 }
601 + if (server_supports("ofs-delta")) {
602 + if (args.verbose)
603 + fprintf(stderr, "Server supports ofs-delta\n");
604 + } else
605 + prefer_ofs_delta = 0;
606 if (everything_local(&ref, nr_match, match)) {
607 packet_flush(fd[1]);
608 goto all_done;
@@ -649,6 +655,11 @@ static int fetch_pack_config(const char *var, const char *value, void *cb)
655 return 0;
656 }
657
658 + if (strcmp(var, "repack.usedeltabaseoffset") == 0) {
659 + prefer_ofs_delta = git_config_bool(var, value);
660 + return 0;
661 + }
662 +
663 return git_default_config(var, value, cb);
664 }
665