{"thread":{"id":"28298","subject":"[PATCH] Support sizes >=2G in various config options accepting 'g' sizes.","startedAt":"2011-09-04T21:03:15Z","lastAt":"2011-09-04T21:03:15Z","messageCount":1,"participants":["Nix"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"174832","messageId":"87obz0nhpo.fsf@spindle.srvr.nix","threadId":"28298","inReplyTo":null,"subject":"[PATCH] Support sizes >=2G in various config options accepting 'g' sizes.","fromName":"Nix","fromEmail":"nix@esperi.org.uk","sentAt":"2011-09-04T21:03:15Z","receivedAt":"2011-09-04T21:03:15Z","isPatch":true,"sender":{"key":"nix@esperi.org.uk","avatar":"https://avatars.githubusercontent.com/u/6503005?v=4"},"body":"The config options core.packedGitWindowSize, core.packedGitLimit,\ncore.deltaBaseCacheLimit and core.bigFileThreshold all claim\nto support suffixes up to and including 'g'.  This implies that\nthey should accept sizes >=2G on 64-bit systems: certainly,\nspecifying a size of 3g should not silently be translated to zero\nor transformed into a large negative value due to integer\noverflow.  However, due to use of git_config_int() rather than\ngit_config_ulong(), that is exactly what happens:\n\n% git config core.bigFileThreshold 2g\n% git gc --aggressive # with extra debugging code to print out\n                      # core.bigfilethreshold after parsing\nbigfilethreshold: -2147483648\n[...]\n\nThis is probably irrelevant for core.deltaBaseCacheLimit, but\nis problematic for the other values.  (It is particularly\nproblematic for core.packedGitLimit, which can't even be set to\nits default value in the config file due to this bug.)\n\nI haven't tried to fix things on 32-bit platforms, because there\nis no real point setting any values to >2G on such platforms\nanyway, and minimal likelihood that anyone would try.  The only\nreal fix possible would be a diagnostic warning of an attempt to\nset a ridiculously high value, unless we want to use 'long long'\neverywhere, which I doubt.\n\nSigned-off-by: Nick Alcock <nix@esperi.org.uk>\n---\n config.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex 4183f80..919f581 100644\n--- a/config.c\n+++ b/config.c\n@@ -550,7 +550,7 @@ static int git_default_core_config(const char *var, const char *value)\n \n \tif (!strcmp(var, \"core.packedgitwindowsize\")) {\n \t\tint pgsz_x2 = getpagesize() * 2;\n-\t\tpacked_git_window_size = git_config_int(var, value);\n+\t\tpacked_git_window_size = git_config_ulong(var, value);\n \n \t\t/* This value must be multiple of (pagesize * 2) */\n \t\tpacked_git_window_size /= pgsz_x2;\n@@ -561,18 +561,18 @@ static int git_default_core_config(const char *var, const char *value)\n \t}\n \n \tif (!strcmp(var, \"core.bigfilethreshold\")) {\n-\t\tlong n = git_config_int(var, value);\n+\t\tlong n = git_config_ulong(var, value);\n \t\tbig_file_threshold = 0 < n ? n : 0;\n \t\treturn 0;\n \t}\n \n \tif (!strcmp(var, \"core.packedgitlimit\")) {\n-\t\tpacked_git_limit = git_config_int(var, value);\n+\t\tpacked_git_limit = git_config_ulong(var, value);\n \t\treturn 0;\n \t}\n \n \tif (!strcmp(var, \"core.deltabasecachelimit\")) {\n-\t\tdelta_base_cache_limit = git_config_int(var, value);\n+\t\tdelta_base_cache_limit = git_config_ulong(var, value);\n \t\treturn 0;\n \t}\n \n-- \n1.7.6.1.138.g03ab.dirty\n"}]}