Skip to content

Commit 2f661de

Browse files
committed
Merge branch 'jc/abbrev-autoscale-config' into pu
* jc/abbrev-autoscale-config: config.abbrev: document the new default that auto-scales
2 parents cbccd36 + bfa3529 commit 2f661de

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
@@ -836,10 +836,16 @@ static int git_default_core_config(const char *var, const char *value)
836836
}
837837

838838
if (!strcmp(var, "core.abbrev")) {
839-
int abbrev = git_config_int(var, value);
840-
if (abbrev < minimum_abbrev || abbrev > 40)
841-
return -1;
842-
default_abbrev = abbrev;
839+
if (!value)
840+
return config_error_nonbool(var);
841+
if (!strcasecmp(value, "auto"))
842+
default_abbrev = -1;
843+
else {
844+
int abbrev = git_config_int(var, value);
845+
if (abbrev < minimum_abbrev || abbrev > 40)
846+
return -1;
847+
default_abbrev = abbrev;
848+
}
843849
return 0;
844850
}
845851

0 commit comments

Comments
 (0)