{"thread":{"id":"11896","subject":"[PATCH] Introduce the config variable pack.packSizeLimit","startedAt":"2008-02-05T14:25:04Z","lastAt":"2008-02-09T20:42:18Z","messageCount":5,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"67517","messageId":"alpine.LSU.1.00.0802051423530.8543@racer.site","threadId":"11896","inReplyTo":null,"subject":"[PATCH] Introduce the config variable pack.packSizeLimit","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-05T14:25:04Z","receivedAt":"2008-02-05T14:25:04Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\n\"git pack-objects\" has the option --max-pack-size to limit the file\nsize of the packs to a certain amount of bytes.  On platforms where\nthe pack file size is limited by filesystem constraints, it is easy\nto forget this option, and this option does not exist for \"git gc\"\nto begin with.\n\nSo introduce a config variable to set the default maximum, but make\nthis overrideable by the command line.\n\nSuggested by Tor Arvid Lund.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n Documentation/config.txt           |    6 ++++++\n Documentation/git-pack-objects.txt |    3 ++-\n builtin-pack-objects.c             |   10 +++++++++-\n t/t5300-pack-object.sh             |    6 ++++++\n 4 files changed, 23 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 4e222f1..3e10feb 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -766,6 +766,12 @@ pack.indexVersion::\n \twhenever the corresponding pack is larger than 2 GB.  Otherwise\n \tthe default is 1.\n \n+pack.packSizeLimit:\n+\tThe default maximum size of a pack.  This setting only affects\n+\tpacking to a file, i.e. the git:// protocol is unaffected.  It\n+\tcan be overridden by the `\\--max-pack-size` option of\n+\tlinkgit:git-repack[1].\n+\n pull.octopus::\n \tThe default merge strategy to use when pulling multiple branches\n \tat once.\ndiff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt\nindex 74cc7c1..8353be1 100644\n--- a/Documentation/git-pack-objects.txt\n+++ b/Documentation/git-pack-objects.txt\n@@ -99,7 +99,8 @@ base-name::\n --max-pack-size=<n>::\n \tMaximum size of each output packfile, expressed in MiB.\n \tIf specified,  multiple packfiles may be created.\n-\tThe default is unlimited.\n+\tThe default is unlimited, unless the config variable\n+\t`pack.packSizeLimit` is set.\n \n --incremental::\n \tThis flag causes an object already in a pack ignored\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex d3efeff..692a761 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -68,7 +68,7 @@ static int allow_ofs_delta;\n static const char *base_name;\n static int progress = 1;\n static int window = 10;\n-static uint32_t pack_size_limit;\n+static uint32_t pack_size_limit, pack_size_limit_cfg;\n static int depth = 50;\n static int delta_search_threads = 1;\n static int pack_to_stdout;\n@@ -1867,6 +1867,10 @@ static int git_pack_config(const char *k, const char *v)\n \t\t\tdie(\"bad pack.indexversion=%d\", pack_idx_default_version);\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"pack.packsizelimit\")) {\n+\t\tpack_size_limit_cfg = git_config_ulong(k, v);\n+\t\treturn 0;\n+\t}\n \treturn git_default_config(k, v);\n }\n \n@@ -2096,6 +2100,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \t\t}\n \t\tif (!prefixcmp(arg, \"--max-pack-size=\")) {\n \t\t\tchar *end;\n+\t\t\tpack_size_limit_cfg = 0;\n \t\t\tpack_size_limit = strtoul(arg+16, &end, 0) * 1024 * 1024;\n \t\t\tif (!arg[16] || *end)\n \t\t\t\tusage(pack_usage);\n@@ -2220,6 +2225,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)\n \tif (pack_to_stdout != !base_name)\n \t\tusage(pack_usage);\n \n+\tif (!pack_to_stdout && !pack_size_limit)\n+\t\tpack_size_limit = pack_size_limit_cfg;\n+\n \tif (pack_to_stdout && pack_size_limit)\n \t\tdie(\"--max-pack-size cannot be used to build a pack for transfer.\");\n \ndiff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh\nindex 4f350dd..cd3c149 100755\n--- a/t/t5300-pack-object.sh\n+++ b/t/t5300-pack-object.sh\n@@ -268,4 +268,10 @@ test_expect_success \\\n     'make sure index-pack detects the SHA1 collision' \\\n     '! git-index-pack -o bad.idx test-3.pack'\n \n+test_expect_success \\\n+    'honor pack.packSizeLimit' \\\n+    'git config pack.packSizeLimit 200 &&\n+     packname_4=$(git pack-objects test-4 <obj-list) &&\n+     test 3 = $(ls test-4-*.pack | wc -l)'\n+\n test_done\n-- \n1.5.4.1178.gd491a5\n"},{"id":"68049","messageId":"7vfxw2g0gb.fsf@gitster.siamese.dyndns.org","threadId":"11896","inReplyTo":"alpine.LSU.1.00.0802051423530.8543@racer.site","subject":"Re: [PATCH] Introduce the config variable pack.packSizeLimit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-09T05:31:32Z","receivedAt":"2008-02-09T05:31:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> \"git pack-objects\" has the option --max-pack-size to limit the file\n> size of the packs to a certain amount of bytes.  On platforms where\n> the pack file size is limited by filesystem constraints, it is easy\n> to forget this option, and this option does not exist for \"git gc\"\n> to begin with.\n>\n> So introduce a config variable to set the default maximum, but make\n> this overrideable by the command line.\n\nThe intention is good and all makes sense.\n\n> +test_expect_success \\\n> +    'honor pack.packSizeLimit' \\\n> +    'git config pack.packSizeLimit 200 &&\n> +     packname_4=$(git pack-objects test-4 <obj-list) &&\n> +     test 3 = $(ls test-4-*.pack | wc -l)'\n> +\n\nWhere does \"3\" come from, and what could break it?\n"},{"id":"68054","messageId":"7vbq6qfz94.fsf@gitster.siamese.dyndns.org","threadId":"11896","inReplyTo":"7vfxw2g0gb.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Introduce the config variable pack.packSizeLimit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-09T05:57:27Z","receivedAt":"2008-02-09T05:57:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n>\n>> +test_expect_success \\\n>> +    'honor pack.packSizeLimit' \\\n>> +    'git config pack.packSizeLimit 200 &&\n>> +     packname_4=$(git pack-objects test-4 <obj-list) &&\n>> +     test 3 = $(ls test-4-*.pack | wc -l)'\n>> +\n>\n> Where does \"3\" come from, and what could break it?\n\nHow about doing it like this, instead?\n\ndiff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh\nindex 4f350dd..3eea478 100755\n--- a/t/t5300-pack-object.sh\n+++ b/t/t5300-pack-object.sh\n@@ -268,4 +268,12 @@ test_expect_success \\\n     'make sure index-pack detects the SHA1 collision' \\\n     '! git-index-pack -o bad.idx test-3.pack'\n \n+test_expect_success 'honor pack.packSizeLimit' '\n+     limit=200 &&\n+     git config pack.packSizeLimit $limit &&\n+     packname_4=$(git pack-objects test-4 <obj-list) &&\n+     bigger=$(find test-4-*.pack -size +${limit}c) &&\n+     test -z \"$bigger\"\n+'\n+\n test_done\n"},{"id":"68078","messageId":"alpine.LSU.1.00.0802091312350.11591@racer.site","threadId":"11896","inReplyTo":"7vbq6qfz94.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Introduce the config variable pack.packSizeLimit","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-09T13:15:07Z","receivedAt":"2008-02-09T13:15:07Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 8 Feb 2008, Junio C Hamano wrote:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n> > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> >\n> >> +test_expect_success \\\n> >> +    'honor pack.packSizeLimit' \\\n> >> +    'git config pack.packSizeLimit 200 &&\n> >> +     packname_4=$(git pack-objects test-4 <obj-list) &&\n> >> +     test 3 = $(ls test-4-*.pack | wc -l)'\n> >> +\n> >\n> > Where does \"3\" come from, and what could break it?\n\nIt was in my test, and as I do not expect the obj-list (as well as the \ncontents it references to change), I just fixed it to 3.\n\n> How about doing it like this, instead?\n> \n> diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh\n> index 4f350dd..3eea478 100755\n> --- a/t/t5300-pack-object.sh\n> +++ b/t/t5300-pack-object.sh\n> @@ -268,4 +268,12 @@ test_expect_success \\\n>      'make sure index-pack detects the SHA1 collision' \\\n>      '! git-index-pack -o bad.idx test-3.pack'\n>  \n> +test_expect_success 'honor pack.packSizeLimit' '\n> +     limit=200 &&\n> +     git config pack.packSizeLimit $limit &&\n> +     packname_4=$(git pack-objects test-4 <obj-list) &&\n> +     bigger=$(find test-4-*.pack -size +${limit}c) &&\n> +     test -z \"$bigger\"\n> +'\n\nSure (with minor modifications).  I was not certain if I could rely on \nfind being available everywhere, and understanding -size.\n\nMinor modification that is necessary: MacOSX' find does not accept a find \ncall like that.  It must be\n\n\tbigger=$(find . -name test-4-*.pack -size +${limit}c) &&\n\nCiao,\nDscho\n"},{"id":"68120","messageId":"7vwspdeuad.fsf@gitster.siamese.dyndns.org","threadId":"11896","inReplyTo":"alpine.LSU.1.00.0802091312350.11591@racer.site","subject":"Re: [PATCH] Introduce the config variable pack.packSizeLimit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-09T20:42:18Z","receivedAt":"2008-02-09T20:42:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Minor modification that is necessary: MacOSX' find does not accept a find \n> call like that.  It must be\n>\n> \tbigger=$(find . -name test-4-*.pack -size +${limit}c) &&\n\nThat looks more traditional, but now you mention it, I agree\nthat it might not be so portable.  I've used \"-size +$size\" in\nAncient Unices, but 'c' suffix is a more recent invention (V7\ndid not have it, neither did 4BSD, IIRC).\n"}]}