path: root/sha1_name.c
diff options
authorJunio C Hamano <>2010-10-28 21:39:13 (GMT)
committerJunio C Hamano <>2010-10-29 00:37:35 (GMT)
commit72a5b561fc1c4286bc7c5b0693afc076af261e1f (patch)
tree0dd2d883abce19c72834be8a5a6c52526f392713 /sha1_name.c
parent7ebee44167fc25b975f5543472c851ab1840af1b (diff)
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 <>
Diffstat (limited to 'sha1_name.c')
1 files changed, 3 insertions, 1 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 484081d..4a226ad 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;