sha1-name: use the_hash_algo when parsing object names
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Jul 16, 2018 at 01:27 UTC
7b38efad5ed4417defaefe04d64adc7d4b55a66e
1 file changed
+7
-5
sha1-name.c
+7
-5
@@ -310,7 +310,7 @@ static int init_object_disambiguation(const char *name, int len,
310
{
311
int i;
312
313
- if (len < MINIMUM_ABBREV || len > GIT_SHA1_HEXSZ)
313
+ if (len < MINIMUM_ABBREV || len > the_hash_algo->hexsz)
314
return -1;
315
316
memset(ds, 0, sizeof(*ds));
@@ -576,6 +576,8 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)
576
struct disambiguate_state ds;
577
struct min_abbrev_data mad;
578
struct object_id oid_ret;
579
+ const unsigned hexsz = the_hash_algo->hexsz;
580
+
581
if (len < 0) {
582
unsigned long count = approximate_object_count();
583
/*
@@ -599,8 +601,8 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)
601
}
602
603
oid_to_hex_r(hex, oid);
602
- if (len == GIT_SHA1_HEXSZ || !len)
603
- return GIT_SHA1_HEXSZ;
604
+ if (len == hexsz || !len)
605
+ return hexsz;
606
607
mad.init_len = len;
608
mad.cur_len = len;
@@ -706,7 +708,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
708
int refs_found = 0;
709
int at, reflog_len, nth_prior = 0;
710
709
- if (len == GIT_SHA1_HEXSZ && !get_oid_hex(str, oid)) {
711
+ if (len == the_hash_algo->hexsz && !get_oid_hex(str, oid)) {
712
if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
713
refs_found = dwim_ref(str, len, &tmp_oid, &real_ref);
714
if (refs_found > 0) {
@@ -750,7 +752,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
752
int detached;
753
754
if (interpret_nth_prior_checkout(str, len, &buf) > 0) {
753
- detached = (buf.len == GIT_SHA1_HEXSZ && !get_oid_hex(buf.buf, oid));
755
+ detached = (buf.len == the_hash_algo->hexsz && !get_oid_hex(buf.buf, oid));
756
strbuf_release(&buf);
757
if (detached)
758
return 0;