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>

brian m. carlson committed Feb 19, 2019 at 00:05 UTC 9c9492e8aafdcc2ec464e9261b78619b05a835f8
1 file changed +6 -5
remote-curl.c
+6 -5
@@ -249,7 +249,7 @@ static struct ref *parse_info_refs(struct discovery *heads)
249 if (data[i] == '\t')
250 mid = &data[i];
251 if (data[i] == '\n') {
252 - if (mid - start != 40)
252 + if (mid - start != the_hash_algo->hexsz)
253 die("%sinfo/refs not valid: is this a git repository?",
254 url.buf);
255 data[i] = 0;
@@ -1107,12 +1107,13 @@ static void parse_fetch(struct strbuf *buf)
1107 const char *name;
1108 struct ref *ref;
1109 struct object_id old_oid;
1110 + const char *q;
1111
1111 - if (get_oid_hex(p, &old_oid))
1112 + if (parse_oid_hex(p, &old_oid, &q))
1113 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)
1117 name = "";
1118 else
1119 die("protocol error: expected sha/ref, got %s'", p);