Skip to content

Commit f04833e

Browse files
Nicolas Pitregitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a2dc04b commit f04833e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

builtin-fetch-pack.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
static int transfer_unpack_limit = -1;
1414
static int fetch_unpack_limit = -1;
1515
static int unpack_limit = 100;
16+
static int prefer_ofs_delta = 1;
1617
static struct fetch_pack_args args = {
1718
/* .uploadpack = */ "git-upload-pack",
1819
};
@@ -200,7 +201,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
200201
(args.use_thin_pack ? " thin-pack" : ""),
201202
(args.no_progress ? " no-progress" : ""),
202203
(args.include_tag ? " include-tag" : ""),
203-
" ofs-delta");
204+
(prefer_ofs_delta ? " ofs-delta" : ""));
204205
else
205206
packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
206207
fetching++;
@@ -597,6 +598,11 @@ static struct ref *do_fetch_pack(int fd[2],
597598
fprintf(stderr, "Server supports side-band\n");
598599
use_sideband = 1;
599600
}
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;
600606
if (everything_local(&ref, nr_match, match)) {
601607
packet_flush(fd[1]);
602608
goto all_done;
@@ -649,6 +655,11 @@ static int fetch_pack_config(const char *var, const char *value, void *cb)
649655
return 0;
650656
}
651657

658+
if (strcmp(var, "repack.usedeltabaseoffset") == 0) {
659+
prefer_ofs_delta = git_config_bool(var, value);
660+
return 0;
661+
}
662+
652663
return git_default_config(var, value, cb);
653664
}
654665

0 commit comments

Comments
 (0)