]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config.abbrev: document the new default that auto-scales
authorJunio C Hamano <gitster@pobox.com>
Wed, 2 Nov 2016 01:34:07 +0000 (18:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Dec 2016 21:17:15 +0000 (13:17 -0800)
We somehow forgot to update the "default is 7" in the
documentation.  Also give a way to explicitly ask the auto-scaling
by setting config.abbrev to "auto".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config.txt
config.c

index a0ab66aae70db90bd18e14ec5bc5c95007b118f7..b02f8a402516e08b7dd5825976e3250748d629f7 100644 (file)
@@ -783,10 +783,11 @@ core.sparseCheckout::
        linkgit:git-read-tree[1] for more information.
 
 core.abbrev::
-       Set the length object names are abbreviated to.  If unspecified,
-       many commands abbreviate to 7 hexdigits, which may not be enough
-       for abbreviated object names to stay unique for sufficiently long
-       time.
+       Set the length object names are abbreviated to.  If
+       unspecified or set to "auto", an appropriate value is
+       computed based on the approximate number of packed objects
+       in your repository, which hopefully is enough for
+       abbreviated object names to stay unique for some time.
 
 add.ignoreErrors::
 add.ignore-errors (deprecated)::
index 83fdecb1bc9f6f31bc625c79c1d3c12ba5b27f77..1c571204ebcca490e2a4b152cfca2e04b98cb3e3 100644 (file)
--- a/config.c
+++ b/config.c
@@ -834,10 +834,16 @@ static int git_default_core_config(const char *var, const char *value)
        }
 
        if (!strcmp(var, "core.abbrev")) {
-               int abbrev = git_config_int(var, value);
-               if (abbrev < minimum_abbrev || abbrev > 40)
-                       return -1;
-               default_abbrev = abbrev;
+               if (!value)
+                       return config_error_nonbool(var);
+               if (!strcasecmp(value, "auto"))
+                       default_abbrev = -1;
+               else {
+                       int abbrev = git_config_int(var, value);
+                       if (abbrev < minimum_abbrev || abbrev > 40)
+                               return error("abbrev length out of range: %d", abbrev);
+                       default_abbrev = abbrev;
+               }
                return 0;
        }