summaryrefslogtreecommitdiff
path: root/remote-curl.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2015-11-10 02:22:22 +0000
committerJeff King <peff@peff.net>2015-11-20 08:02:05 -0500
commit8338c911d1c22a6d86d694003a1fa213cbe11bcf (patch)
tree0fa7fbce2ff88198803a839a0460a33e055e87b8 /remote-curl.c
parent854ecb9cadde1063883e2a74ae6b8ea46c0a451a (diff)
downloadgit-8338c911d1c22a6d86d694003a1fa213cbe11bcf.tar.gz
parse_fetch: convert to use struct object_id
Convert the parse_fetch function to use struct object_id. Remove the strlen check as get_oid_hex will fail safely on receiving a too-short NUL-terminated string. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'remote-curl.c')
-rw-r--r--remote-curl.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/remote-curl.c b/remote-curl.c
index bc3af79e4a..f404faf0f4 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -803,19 +803,19 @@ static void parse_fetch(struct strbuf *buf)
if (skip_prefix(buf->buf, "fetch ", &p)) {
const char *name;
struct ref *ref;
- unsigned char old_sha1[20];
+ struct object_id old_oid;
- if (strlen(p) < 40 || get_sha1_hex(p, old_sha1))
+ if (get_oid_hex(p, &old_oid))
die("protocol error: expected sha/ref, got %s'", p);
- if (p[40] == ' ')
- name = p + 41;
- else if (!p[40])
+ if (p[GIT_SHA1_HEXSZ] == ' ')
+ name = p + GIT_SHA1_HEXSZ + 1;
+ else if (!p[GIT_SHA1_HEXSZ])
name = "";
else
die("protocol error: expected sha/ref, got %s'", p);
ref = alloc_ref(name);
- hashcpy(ref->old_oid.hash, old_sha1);
+ oidcpy(&ref->old_oid, &old_oid);
*list = ref;
list = &ref->next;