Skip to content

Commit bfa3529

Browse files
committed
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 <[email protected]>
1 parent be5a750 commit bfa3529

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

Documentation/config.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,10 +783,11 @@ core.sparseCheckout::
783783
linkgit:git-read-tree[1] for more information.
784784

785785
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.
790791

791792
add.ignoreErrors::
792793
add.ignore-errors (deprecated)::

config.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -834,10 +834,16 @@ static int git_default_core_config(const char *var, const char *value)
834834
}
835835

836836
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 -1;
845+
default_abbrev = abbrev;
846+
}
841847
return 0;
842848
}
843849

0 commit comments

Comments
 (0)