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>
This commit is contained in:
parent
4b048c917f
commit
7b38efad5e
12
sha1-name.c
12
sha1-name.c
@ -310,7 +310,7 @@ static int init_object_disambiguation(const char *name, int len,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (len < MINIMUM_ABBREV || len > GIT_SHA1_HEXSZ)
|
if (len < MINIMUM_ABBREV || len > the_hash_algo->hexsz)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memset(ds, 0, sizeof(*ds));
|
memset(ds, 0, sizeof(*ds));
|
||||||
@ -576,6 +576,8 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)
|
|||||||
struct disambiguate_state ds;
|
struct disambiguate_state ds;
|
||||||
struct min_abbrev_data mad;
|
struct min_abbrev_data mad;
|
||||||
struct object_id oid_ret;
|
struct object_id oid_ret;
|
||||||
|
const unsigned hexsz = the_hash_algo->hexsz;
|
||||||
|
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
unsigned long count = approximate_object_count();
|
unsigned long count = approximate_object_count();
|
||||||
/*
|
/*
|
||||||
@ -599,8 +601,8 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
oid_to_hex_r(hex, oid);
|
oid_to_hex_r(hex, oid);
|
||||||
if (len == GIT_SHA1_HEXSZ || !len)
|
if (len == hexsz || !len)
|
||||||
return GIT_SHA1_HEXSZ;
|
return hexsz;
|
||||||
|
|
||||||
mad.init_len = len;
|
mad.init_len = len;
|
||||||
mad.cur_len = len;
|
mad.cur_len = len;
|
||||||
@ -706,7 +708,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
|
|||||||
int refs_found = 0;
|
int refs_found = 0;
|
||||||
int at, reflog_len, nth_prior = 0;
|
int at, reflog_len, nth_prior = 0;
|
||||||
|
|
||||||
if (len == GIT_SHA1_HEXSZ && !get_oid_hex(str, oid)) {
|
if (len == the_hash_algo->hexsz && !get_oid_hex(str, oid)) {
|
||||||
if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
|
if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
|
||||||
refs_found = dwim_ref(str, len, &tmp_oid, &real_ref);
|
refs_found = dwim_ref(str, len, &tmp_oid, &real_ref);
|
||||||
if (refs_found > 0) {
|
if (refs_found > 0) {
|
||||||
@ -750,7 +752,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid,
|
|||||||
int detached;
|
int detached;
|
||||||
|
|
||||||
if (interpret_nth_prior_checkout(str, len, &buf) > 0) {
|
if (interpret_nth_prior_checkout(str, len, &buf) > 0) {
|
||||||
detached = (buf.len == GIT_SHA1_HEXSZ && !get_oid_hex(buf.buf, oid));
|
detached = (buf.len == the_hash_algo->hexsz && !get_oid_hex(buf.buf, oid));
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
if (detached)
|
if (detached)
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user