git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Support sizes >=2G in various config options accepting 'g' sizes.

From
Nix <nix@esperi.org.uk>
Date
Sep 4, 2011, 21:03 UTC
Message-ID
<87obz0nhpo.fsf@spindle.srvr.nix>

The config options core.packedGitWindowSize, core.packedGitLimit, core.deltaBaseCacheLimit and core.bigFileThreshold all claim to support suffixes up to and including 'g'. This implies that they should accept sizes >=2G on 64-bit systems: certainly, specifying a size of 3g should not silently be translated to zero or transformed into a large negative value due to integer overflow. However, due to use of git_config_int() rather than git_config_ulong(), that is exactly what happens:

% git config core.bigFileThreshold 2g
% git gc --aggressive # with extra debugging code to print out
                      # core.bigfilethreshold after parsing
bigfilethreshold: -2147483648
[...]

This is probably irrelevant for core.deltaBaseCacheLimit, but is problematic for the other values. (It is particularly problematic for core.packedGitLimit, which can't even be set to its default value in the config file due to this bug.)

I haven't tried to fix things on 32-bit platforms, because there is no real point setting any values to >2G on such platforms anyway, and minimal likelihood that anyone would try. The only real fix possible would be a diagnostic warning of an attempt to set a ridiculously high value, unless we want to use 'long long' everywhere, which I doubt.

Signed-off-by: Nick Alcock <nix@esperi.org.uk>
---
 config.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/config.c b/config.c
index 4183f80..919f581 100644
--- a/config.c
+++ b/config.c
@@ -550,7 +550,7 @@ static int git_default_core_config(const char *var, const char *value)
 
 	if (!strcmp(var, "core.packedgitwindowsize")) {
 		int pgsz_x2 = getpagesize() * 2;
-		packed_git_window_size = git_config_int(var, value);
+		packed_git_window_size = git_config_ulong(var, value);
 
 		/* This value must be multiple of (pagesize * 2) */
 		packed_git_window_size /= pgsz_x2;
@@ -561,18 +561,18 @@ static int git_default_core_config(const char *var, const char *value)
 	}
 
 	if (!strcmp(var, "core.bigfilethreshold")) {
-		long n = git_config_int(var, value);
+		long n = git_config_ulong(var, value);
 		big_file_threshold = 0 < n ? n : 0;
 		return 0;
 	}
 
 	if (!strcmp(var, "core.packedgitlimit")) {
-		packed_git_limit = git_config_int(var, value);
+		packed_git_limit = git_config_ulong(var, value);
 		return 0;
 	}
 
 	if (!strcmp(var, "core.deltabasecachelimit")) {
-		delta_base_cache_limit = git_config_int(var, value);
+		delta_base_cache_limit = git_config_ulong(var, value);
 		return 0;
 	}
 
-- 
1.7.6.1.138.g03ab.dirty
Message 1 of 1 in “Support sizes >=2G in various config options accepting 'g' sizes.”
  1. Support sizes >=2G in various config options accepting 'g' sizes.Nix, Sep 4, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.