{"thread":{"id":"10579","subject":"[PATCH] make the pack index version configurable","startedAt":"2007-11-02T03:26:04Z","lastAt":"2007-11-02T04:01:25Z","messageCount":3,"participants":["Nicolas Pitre","David Symonds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57915","messageId":"alpine.LFD.0.9999.0711012312480.21255@xanadu.home","threadId":"10579","inReplyTo":null,"subject":"[PATCH] make the pack index version configurable","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-11-02T03:26:04Z","receivedAt":"2007-11-02T03:26:04Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"It is a good idea to use pack index version 2 all the time since it has\nproper protection against propagation of certain pack corruptions when\nrepacking which is not possible with index version 1, as demonstrated\nin test t5302.\n\nHence this config option.\n\nThe default is still pack index version 1.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex d4a476e..862b79e 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -660,6 +660,15 @@ pack.threads::\n \tmachines. The required amount of memory for the delta search window\n \tis however multiplied by the number of threads.\n \n+pack.indexVersion::\n+\tSpecify the default pack index version.  Valid values are 1 for\n+\tlegacy pack index used by Git versions prior to 1.5.2, and 2 for\n+\tthe new pack index with capabilities for packs larger than 4 GB\n+\tas well as proper protection against the repacking of corrupted\n+\tpacks.  Version 2 is selected and this config option ignored\n+\twhenever the corresponding pack is larger than 2 GB.  Otherwise\n+\tthe default is 1.\n+\n pull.octopus::\n \tThe default merge strategy to use when pulling multiple branches\n \tat once.\ndiff --git a/builtin-pack-objects.c b/builtin-pack-objects.c\nindex 25ec65d..e923689 100644\n--- a/builtin-pack-objects.c\n+++ b/builtin-pack-objects.c\n@@ -1768,6 +1768,12 @@ static int git_pack_config(const char *k, const char *v)\n #endif\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"pack.indexversion\")) {\n+\t\tpack_idx_default_version = git_config_int(k, v);\n+\t\tif (pack_idx_default_version > 2)\n+\t\t\tdie(\"bad pack.indexversion=%d\", pack_idx_default_version);\n+\t\treturn 0;\n+\t}\n \treturn git_default_config(k, v);\n }\n \ndiff --git a/index-pack.c b/index-pack.c\nindex 61ea762..715a5bb 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -683,6 +683,17 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n \t}\n }\n \n+static int git_index_pack_config(const char *k, const char *v)\n+{\n+\tif (!strcmp(k, \"pack.indexversion\")) {\n+\t\tpack_idx_default_version = git_config_int(k, v);\n+\t\tif (pack_idx_default_version > 2)\n+\t\t\tdie(\"bad pack.indexversion=%d\", pack_idx_default_version);\n+\t\treturn 0;\n+\t}\n+\treturn git_default_config(k, v);\n+}\n+\n int main(int argc, char **argv)\n {\n \tint i, fix_thin_pack = 0;\n@@ -693,6 +704,8 @@ int main(int argc, char **argv)\n \tstruct pack_idx_entry **idx_objects;\n \tunsigned char sha1[20];\n \n+\tgit_config(git_index_pack_config);\n+\n \tfor (i = 1; i < argc; i++) {\n \t\tchar *arg = argv[i];\n \n"},{"id":"57918","messageId":"ee77f5c20711012042r39c6303em2a8140e8348051d@mail.gmail.com","threadId":"10579","inReplyTo":"alpine.LFD.0.9999.0711012312480.21255@xanadu.home","subject":"Re: [PATCH] make the pack index version configurable","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-02T03:42:02Z","receivedAt":"2007-11-02T03:42:02Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"On 11/2/07, Nicolas Pitre <nico@cam.org> wrote:\n>\n> +pack.indexVersion::\n> +       Specify the default pack index version.  Valid values are 1 for\n> +       legacy pack index used by Git versions prior to 1.5.2, and 2 for\n> +       the new pack index with capabilities for packs larger than 4 GB\n> +       as well as proper protection against the repacking of corrupted\n> +       packs.  Version 2 is selected and this config option ignored\n> +       whenever the corresponding pack is larger than 2 GB.  Otherwise\n> +       the default is 1.\n\nIf you're trying to force a previous pack version for some reason\n(backward compatibility, or whatever), this \"feature\" of automatic\nforcing version 2 for 2 GB packs might come as a nasty suprise.\nWouldn't it be better to fail with an error?\n\n\nDave.\n"},{"id":"57924","messageId":"alpine.LFD.0.9999.0711012345220.21255@xanadu.home","threadId":"10579","inReplyTo":"ee77f5c20711012042r39c6303em2a8140e8348051d@mail.gmail.com","subject":"Re: [PATCH] make the pack index version configurable","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-11-02T04:01:25Z","receivedAt":"2007-11-02T04:01:25Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Fri, 2 Nov 2007, David Symonds wrote:\n\n> On 11/2/07, Nicolas Pitre <nico@cam.org> wrote:\n> >\n> > +pack.indexVersion::\n> > +       Specify the default pack index version.  Valid values are 1 for\n> > +       legacy pack index used by Git versions prior to 1.5.2, and 2 for\n> > +       the new pack index with capabilities for packs larger than 4 GB\n> > +       as well as proper protection against the repacking of corrupted\n> > +       packs.  Version 2 is selected and this config option ignored\n> > +       whenever the corresponding pack is larger than 2 GB.  Otherwise\n> > +       the default is 1.\n> \n> If you're trying to force a previous pack version for some reason\n> (backward compatibility, or whatever), this \"feature\" of automatic\n> forcing version 2 for 2 GB packs might come as a nasty suprise.\n> Wouldn't it be better to fail with an error?\n\nNo.  The fact is that you don't know in advance what the pack size will \nbe, and reaching that limit might take a long while already if \nrepacking, or even more so if the pack is fetched over a network \nconnection.  That would be wasteful to simply throw away all the whole \nrepack/download with an error which would be an even nastier surprise at \nthat point just because you specified index v1.\n\nAnd such a pack would be impossible to work with using an old Git \nversion anyway, so the old Git version will happily give you the error, \nsuggesting that you upgrade to a later version.\n\nAnd this has been the implemented behavior for the last 7 months \nalready.\n\nAnd the idea is to switch the default to version 2 eventually.\n\nEtc.\n\n\nNicolas\n"}]}