config.abbrev: document the new default that auto-scales
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>
Junio C Hamano committed
Nov 1, 2016 at 18:34 UTC
48d5014dd42cc4a4465162c9807eaa253715e105
2 files changed
+15
-8
Documentation/config.txt
+5
-4
@@ -783,10 +783,11 @@ core.sparseCheckout::
783
linkgit:git-read-tree[1] for more information.
784
785
core.abbrev::
786
- Set the length object names are abbreviated to. If unspecified,
787
- many commands abbreviate to 7 hexdigits, which may not be enough
788
- for abbreviated object names to stay unique for sufficiently long
789
- time.
786
+ Set the length object names are abbreviated to. If
787
+ unspecified or set to "auto", an appropriate value is
788
+ computed based on the approximate number of packed objects
789
+ in your repository, which hopefully is enough for
790
+ abbreviated object names to stay unique for some time.
791
792
add.ignoreErrors::
793
add.ignore-errors (deprecated)::
config.c
+10
-4
@@ -834,10 +834,16 @@ static int git_default_core_config(const char *var, const char *value)
834
}
835
836
if (!strcmp(var, "core.abbrev")) {
837
- int abbrev = git_config_int(var, value);
838
- if (abbrev < minimum_abbrev || abbrev > 40)
839
- return -1;
840
- default_abbrev = abbrev;
837
+ if (!value)
838
+ return config_error_nonbool(var);
839
+ if (!strcasecmp(value, "auto"))
840
+ default_abbrev = -1;
841
+ else {
842
+ int abbrev = git_config_int(var, value);
843
+ if (abbrev < minimum_abbrev || abbrev > 40)
844
+ return error("abbrev length out of range: %d", abbrev);
845
+ default_abbrev = abbrev;
846
+ }
847
return 0;
848
}
849