Skip to content

Commit 32677e8

Browse files
committed
Merge branch 'jc/longer-disambiguation-fix' into jch
* jc/longer-disambiguation-fix: abbrev: allow extending beyond 20 chars to disambiguate
2 parents 869f44a + 99eb1de commit 32677e8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

object-name.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ static unsigned msb(unsigned long val)
680680
struct min_abbrev_data {
681681
unsigned int init_len;
682682
unsigned int cur_len;
683+
unsigned int max_len;
683684
char *hex;
684685
struct repository *repo;
685686
const struct object_id *oid;
@@ -699,12 +700,12 @@ static inline char get_hex_char_from_oid(const struct object_id *oid,
699700
static int extend_abbrev_len(const struct object_id *oid, void *cb_data)
700701
{
701702
struct min_abbrev_data *mad = cb_data;
702-
703703
unsigned int i = mad->init_len;
704+
704705
while (mad->hex[i] && mad->hex[i] == get_hex_char_from_oid(oid, i))
705706
i++;
706707

707-
if (i < GIT_MAX_RAWSZ && i >= mad->cur_len)
708+
if (mad->cur_len <= i && i < mad->max_len)
708709
mad->cur_len = i + 1;
709710

710711
return 0;
@@ -864,6 +865,7 @@ int repo_find_unique_abbrev_r(struct repository *r, char *hex,
864865
mad.repo = r;
865866
mad.init_len = len;
866867
mad.cur_len = len;
868+
mad.max_len = hexsz;
867869
mad.hex = hex;
868870
mad.oid = oid;
869871

0 commit comments

Comments
 (0)