{"thread":{"id":"9937","subject":"[PATCH 4/5] Ensure builtin-fetch honors {fetch,transfer}.unpackLimit","startedAt":"2007-09-19T04:49:39Z","lastAt":"2007-09-19T04:49:39Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"53547","messageId":"20070919044939.GD17107@spearce.org","threadId":"9937","inReplyTo":null,"subject":"[PATCH 4/5] Ensure builtin-fetch honors {fetch,transfer}.unpackLimit","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-09-19T04:49:39Z","receivedAt":"2007-09-19T04:49:39Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"The only way to configure the unpacking limit is currently through\nthe .git/config (or ~/.gitconfig) mechanism as we have no existing\ncommand line option interface to control this threshold on a per\ninvocation basis.  This was intentional by design as the storage\npolicy of the repository should be a repository-wide decision and\nshould not be subject to variations made on individual command\nexecutions.\n\nEarlier builtin-fetch was bypassing the unpacking limit chosen by\nthe user through the configuration file as it did not reread the\nconfiguration options through fetch_pack_config if we called the\ninternal fetch_pack() API directly.  We now ensure we always run the\nconfig file through fetch_pack_config at least once in this process,\nthereby setting our unpackLimit properly.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n builtin-fetch-pack.c |   19 +++++++++++++------\n transport.c          |    9 ---------\n transport.h          |    3 ---\n 3 files changed, 13 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c\nindex 77eb181..d128915 100644\n--- a/builtin-fetch-pack.c\n+++ b/builtin-fetch-pack.c\n@@ -670,18 +670,24 @@ static int fetch_pack_config(const char *var, const char *value)\n \n static struct lock_file lock;\n \n-int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n+static void fetch_pack_setup()\n {\n-\tint i, ret, nr_heads;\n-\tstruct ref *ref;\n-\tchar *dest = NULL, **heads;\n-\n+\tstatic int did_setup;\n+\tif (did_setup)\n+\t\treturn;\n \tgit_config(fetch_pack_config);\n-\n \tif (0 <= transfer_unpack_limit)\n \t\tunpack_limit = transfer_unpack_limit;\n \telse if (0 <= fetch_unpack_limit)\n \t\tunpack_limit = fetch_unpack_limit;\n+\tdid_setup = 1;\n+}\n+\n+int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n+{\n+\tint i, ret, nr_heads;\n+\tstruct ref *ref;\n+\tchar *dest = NULL, **heads;\n \n \tnr_heads = 0;\n \theads = NULL;\n@@ -760,6 +766,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,\n \tstruct ref *ref;\n \tstruct stat st;\n \n+\tfetch_pack_setup();\n \tmemcpy(&args, my_args, sizeof(args));\n \tif (args.depth > 0) {\n \t\tif (stat(git_path(\"shallow\"), &st))\ndiff --git a/transport.c b/transport.c\nindex 85f5b1e..a1d0a3c 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -242,11 +242,7 @@ static int close_bundle(struct transport *transport)\n struct git_transport_data {\n \tunsigned thin : 1;\n \tunsigned keep : 1;\n-\n-\tint unpacklimit;\n-\n \tint depth;\n-\n \tconst char *uploadpack;\n \tconst char *receivepack;\n };\n@@ -267,9 +263,6 @@ static int set_git_option(struct transport *connection,\n \t} else if (!strcmp(name, TRANS_OPT_KEEP)) {\n \t\tdata->keep = !!value;\n \t\treturn 0;\n-\t} else if (!strcmp(name, TRANS_OPT_UNPACKLIMIT)) {\n-\t\tdata->unpacklimit = atoi(value);\n-\t\treturn 0;\n \t} else if (!strcmp(name, TRANS_OPT_DEPTH)) {\n \t\tif (!value)\n \t\t\tdata->depth = 0;\n@@ -318,7 +311,6 @@ static int fetch_refs_via_pack(struct transport *transport,\n \targs.uploadpack = data->uploadpack;\n \targs.keep_pack = data->keep;\n \targs.lock_pack = 1;\n-\targs.unpacklimit = data->unpacklimit;\n \targs.use_thin_pack = data->thin;\n \targs.verbose = transport->verbose;\n \targs.depth = data->depth;\n@@ -435,7 +427,6 @@ struct transport *transport_get(struct remote *remote, const char *url)\n \t\tdata->receivepack = \"git-receive-pack\";\n \t\tif (remote && remote->receivepack)\n \t\t\tdata->receivepack = remote->receivepack;\n-\t\tdata->unpacklimit = -1;\n \t}\n \n \treturn ret;\ndiff --git a/transport.h b/transport.h\nindex 3e332ff..6e318e4 100644\n--- a/transport.h\n+++ b/transport.h\n@@ -47,9 +47,6 @@ struct transport *transport_get(struct remote *, const char *);\n /* Keep the pack that was transferred if not null */\n #define TRANS_OPT_KEEP \"keep\"\n \n-/* Unpack the objects if fewer than this number of objects are fetched */\n-#define TRANS_OPT_UNPACKLIMIT \"unpacklimit\"\n-\n /* Limit the depth of the fetch if not null */\n #define TRANS_OPT_DEPTH \"depth\"\n \n-- \n1.5.3.1.195.gadd6\n"}]}