@matheusbsbs / matheus-bagliano / commits / 50ab5fd3fc
Fork 0

Ensure builtin-fetch honors {fetch,transfer}.unpackLimit

The only way to configure the unpacking limit is currently through the .git/config (or ~/.gitconfig) mechanism as we have no existing command line option interface to control this threshold on a per invocation basis. This was intentional by design as the storage policy of the repository should be a repository-wide decision and should not be subject to variations made on individual command executions. Earlier builtin-fetch was bypassing the unpacking limit chosen by the user through the configuration file as it did not reread the configuration options through fetch_pack_config if we called the internal fetch_pack() API directly. We now ensure we always run the config file through fetch_pack_config at least once in this process, thereby setting our unpackLimit properly. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Shawn O. Pearce committed Sep 19, 2007 at 00:49 UTC 50ab5fd3fc16fbe01170059977533fa2c7c4d448
3 files changed +13 -18
builtin-fetch-pack.c
+13 -6
@@ -670,18 +670,24 @@ static int fetch_pack_config(const char *var, const char *value)
670
671 static struct lock_file lock;
672
673 -int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
673 +static void fetch_pack_setup(void)
674 {
675 - int i, ret, nr_heads;
676 - struct ref *ref;
677 - char *dest = NULL, **heads;
678 -
675 + static int did_setup;
676 + if (did_setup)
677 + return;
678 git_config(fetch_pack_config);
680 -
679 if (0 <= transfer_unpack_limit)
680 unpack_limit = transfer_unpack_limit;
681 else if (0 <= fetch_unpack_limit)
682 unpack_limit = fetch_unpack_limit;
683 + did_setup = 1;
684 +}
685 +
686 +int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
687 +{
688 + int i, ret, nr_heads;
689 + struct ref *ref;
690 + char *dest = NULL, **heads;
691
692 nr_heads = 0;
693 heads = NULL;
@@ -760,6 +766,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
766 struct ref *ref;
767 struct stat st;
768
769 + fetch_pack_setup();
770 memcpy(&args, my_args, sizeof(args));
771 if (args.depth > 0) {
772 if (stat(git_path("shallow"), &st))
transport.c
-9
@@ -242,11 +242,7 @@ static int close_bundle(struct transport *transport)
242 struct git_transport_data {
243 unsigned thin : 1;
244 unsigned keep : 1;
245 -
246 - int unpacklimit;
247 -
245 int depth;
249 -
246 const char *uploadpack;
247 const char *receivepack;
248 };
@@ -267,9 +263,6 @@ static int set_git_option(struct transport *connection,
263 } else if (!strcmp(name, TRANS_OPT_KEEP)) {
264 data->keep = !!value;
265 return 0;
270 - } else if (!strcmp(name, TRANS_OPT_UNPACKLIMIT)) {
271 - data->unpacklimit = atoi(value);
272 - return 0;
266 } else if (!strcmp(name, TRANS_OPT_DEPTH)) {
267 if (!value)
268 data->depth = 0;
@@ -318,7 +311,6 @@ static int fetch_refs_via_pack(struct transport *transport,
311 args.uploadpack = data->uploadpack;
312 args.keep_pack = data->keep;
313 args.lock_pack = 1;
321 - args.unpacklimit = data->unpacklimit;
314 args.use_thin_pack = data->thin;
315 args.verbose = transport->verbose;
316 args.depth = data->depth;
@@ -435,7 +427,6 @@ struct transport *transport_get(struct remote *remote, const char *url)
427 data->receivepack = "git-receive-pack";
428 if (remote && remote->receivepack)
429 data->receivepack = remote->receivepack;
438 - data->unpacklimit = -1;
430 }
431
432 return ret;
transport.h
-3
@@ -47,9 +47,6 @@ struct transport *transport_get(struct remote *, const char *);
47 /* Keep the pack that was transferred if not null */
48 #define TRANS_OPT_KEEP "keep"
49
50 -/* Unpack the objects if fewer than this number of objects are fetched */
51 -#define TRANS_OPT_UNPACKLIMIT "unpacklimit"
52 -
50 /* Limit the depth of the fetch if not null */
51 #define TRANS_OPT_DEPTH "depth"
52