aboutsummaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-10-28 14:39:13 -0700
committerJunio C Hamano <gitster@pobox.com>2010-10-28 17:37:35 -0700
commit72a5b561fc1c4286bc7c5b0693afc076af261e1f (patch)
tree0dd2d883abce19c72834be8a5a6c52526f392713 /sha1_name.c
parent7ebee44167fc25b975f5543472c851ab1840af1b (diff)
downloadgit-72a5b561fc1c4286bc7c5b0693afc076af261e1f.tar.gz
git-72a5b561fc1c4286bc7c5b0693afc076af261e1f.tar.xz
core.abbrevguard: Ensure short object names stay unique a bit longer
Even though git makes sure that it uses enough hexdigits to show an abbreviated object name unambiguously, as more objects are added to the repository over time, a short name that used to be unique will stop being unique. Git uses this many extra hexdigits that are more than necessary to make the object name currently unique, in the hope that its output will stay unique a bit longer. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 484081de8..4a226adec 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -206,7 +206,9 @@ const char *find_unique_abbrev(const unsigned char *sha1, int len)
if (exists
? !status
: status == SHORT_NAME_NOT_FOUND) {
- hex[len] = 0;
+ int cut_at = len + unique_abbrev_extra_length;
+ cut_at = (cut_at < 40) ? cut_at : 40;
+ hex[cut_at] = 0;
return hex;
}
len++;