]> git.ipfire.org Git - thirdparty/git.git/commit - sha1_name.c
abbrev: auto size the default abbreviation
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 1 Oct 2016 00:19:37 +0000 (17:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Oct 2016 19:54:29 +0000 (12:54 -0700)
commite6c587c733b4634030b353f4024794b08bc86892
tree6ff539da43f3c8030efc7c59d9fb35e9ed167a59
parent7b5b7721affae7040cac77d647a5ec8628f0f845
abbrev: auto size the default abbreviation

In fairly early days we somehow decided to abbreviate object names
down to 7-hexdigits, but as projects grow, it is becoming more and
more likely to see such a short object names made in earlier days
and recorded in the log messages no longer unique.

Currently the Linux kernel project needs 11 to 12 hexdigits, while
Git itself needs 10 hexdigits to uniquely identify the objects they
have, while many smaller projects may still be fine with the
original 7-hexdigit default.  One-size does not fit all projects.

Introduce a mechanism, where we estimate the number of objects in
the repository upon the first request to abbreviate an object name
with the default setting and come up with a sane default for the
repository.  Based on the expectation that we would see collision in
a repository with 2^(2N) objects when using object names shortened
to first N bits, use sufficient number of hexdigits to cover the
number of objects in the repository.  Each hexdigit (4-bits) we add
to the shortened name allows us to have four times (2-bits) as many
objects in the repository.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
environment.c
sha1_name.c