summaryrefslogtreecommitdiff
path: root/remote-curl.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2019-02-19 00:05:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-04-01 02:57:39 (GMT)
commit9c9492e8aafdcc2ec464e9261b78619b05a835f8 (patch)
treee2013776c92dea1cc7a794a9d0b43e71a0bb7c23 /remote-curl.c
parent05dfc7cac4a0e0dcd6c7b2f63009c03f96dba1c0 (diff)
downloadgit-9c9492e8aafdcc2ec464e9261b78619b05a835f8.zip
git-9c9492e8aafdcc2ec464e9261b78619b05a835f8.tar.gz
git-9c9492e8aafdcc2ec464e9261b78619b05a835f8.tar.bz2
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>
Diffstat (limited to 'remote-curl.c')
-rw-r--r--remote-curl.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 5b44794..cc74ff3 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -249,7 +249,7 @@ static struct ref *parse_info_refs(struct discovery *heads)
if (data[i] == '\t')
mid = &data[i];
if (data[i] == '\n') {
- if (mid - start != 40)
+ if (mid - start != the_hash_algo->hexsz)
die("%sinfo/refs not valid: is this a git repository?",
url.buf);
data[i] = 0;
@@ -1107,12 +1107,13 @@ static void parse_fetch(struct strbuf *buf)
const char *name;
struct ref *ref;
struct object_id old_oid;
+ const char *q;
- if (get_oid_hex(p, &old_oid))
+ if (parse_oid_hex(p, &old_oid, &q))
die("protocol error: expected sha/ref, got %s'", p);
- if (p[GIT_SHA1_HEXSZ] == ' ')
- name = p + GIT_SHA1_HEXSZ + 1;
- else if (!p[GIT_SHA1_HEXSZ])
+ if (*q == ' ')
+ name = q + 1;
+ else if (!*q)
name = "";
else
die("protocol error: expected sha/ref, got %s'", p);