Skip to content

Commit 9c9492e

Browse files
bk2204gitster
authored andcommitted
remote-curl: make hash size independent
Change one hard-coded use of the constant 40 to a reference to the_hash_algo. In addition, switch a use of get_oid_hex to parse_oid_hex to avoid the need to use a constant. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 05dfc7c commit 9c9492e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

remote-curl.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static struct ref *parse_info_refs(struct discovery *heads)
249249
if (data[i] == '\t')
250250
mid = &data[i];
251251
if (data[i] == '\n') {
252-
if (mid - start != 40)
252+
if (mid - start != the_hash_algo->hexsz)
253253
die("%sinfo/refs not valid: is this a git repository?",
254254
url.buf);
255255
data[i] = 0;
@@ -1107,12 +1107,13 @@ static void parse_fetch(struct strbuf *buf)
11071107
const char *name;
11081108
struct ref *ref;
11091109
struct object_id old_oid;
1110+
const char *q;
11101111

1111-
if (get_oid_hex(p, &old_oid))
1112+
if (parse_oid_hex(p, &old_oid, &q))
11121113
die("protocol error: expected sha/ref, got %s'", p);
1113-
if (p[GIT_SHA1_HEXSZ] == ' ')
1114-
name = p + GIT_SHA1_HEXSZ + 1;
1115-
else if (!p[GIT_SHA1_HEXSZ])
1114+
if (*q == ' ')
1115+
name = q + 1;
1116+
else if (!*q)
11161117
name = "";
11171118
else
11181119
die("protocol error: expected sha/ref, got %s'", p);

0 commit comments

Comments
 (0)