Merge branch 'jc/abbrev-autoscale-config'
authorJunio C Hamano <gitster@pobox.com>
Tue, 10 Jan 2017 23:24:26 +0000 (15:24 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Jan 2017 23:24:26 +0000 (15:24 -0800)
Recent update to the default abbreviation length that auto-scales
lacked documentation update, which has been corrected.

* jc/abbrev-autoscale-config:
config.abbrev: document the new default that auto-scales

Documentation/config.txt
config.c
index 1abf078c4e1c79ee11b05c2a26d83ba28c809a66..506431267ed0ef15bce2570d3f1bf69e7268e8f0 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 2f1aef742ef5c526d6dc1083c490717b1f782d30..0b9c1b62bbb5fb04a907f8794b8d375ffcf396ca 100644 (file)
--- a/config.c
+++ b/config.c
@@ -836,10 +836,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;
        }