]> git.ipfire.org Git - thirdparty/git.git/commit - config.c
Support sizes >=2G in various config options accepting 'g' sizes.
authorNick Alcock <nix@esperi.org.uk>
Wed, 2 Nov 2011 15:46:23 +0000 (15:46 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 6 Nov 2011 06:10:43 +0000 (23:10 -0700)
commitebaa1bd407745c4b4c1c0f20c322929fc4371467
tree78b9c99339d486e2c3013aa68b87274834d7c48f
parent97000ba6e21d25581222e11c36db4bb88c05adcd
Support sizes >=2G in various config options accepting 'g' sizes.

The config options core.packedGitWindowSize, core.packedGitLimit,
core.deltaBaseCacheLimit, core.bigFileThreshold, pack.windowMemory and
pack.packSizeLimit 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.)

This fixes things for 32-bit platforms as well.  They get the usual bad
config error if an overlarge value is specified, e.g.:

fatal: bad config value for 'core.bigfilethreshold' in /home/nix/.gitconfig

This is detected in all cases, even if the 32-bit platform has no size
larger than 'long'.  For signed integral configuration values, we also
detect the case where the value is too large for the signed type but
not the unsigned type.

Signed-off-by: Nick Alcock <nix@esperi.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config.c