Skip to content

Commit 8338c91

Browse files
bk2204peff
authored andcommitted
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 <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 854ecb9 commit 8338c91

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

remote-curl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,19 +803,19 @@ static void parse_fetch(struct strbuf *buf)
803803
if (skip_prefix(buf->buf, "fetch ", &p)) {
804804
const char *name;
805805
struct ref *ref;
806-
unsigned char old_sha1[20];
806+
struct object_id old_oid;
807807

808-
if (strlen(p) < 40 || get_sha1_hex(p, old_sha1))
808+
if (get_oid_hex(p, &old_oid))
809809
die("protocol error: expected sha/ref, got %s'", p);
810-
if (p[40] == ' ')
811-
name = p + 41;
812-
else if (!p[40])
810+
if (p[GIT_SHA1_HEXSZ] == ' ')
811+
name = p + GIT_SHA1_HEXSZ + 1;
812+
else if (!p[GIT_SHA1_HEXSZ])
813813
name = "";
814814
else
815815
die("protocol error: expected sha/ref, got %s'", p);
816816

817817
ref = alloc_ref(name);
818-
hashcpy(ref->old_oid.hash, old_sha1);
818+
oidcpy(&ref->old_oid, &old_oid);
819819

820820
*list = ref;
821821
list = &ref->next;

0 commit comments

Comments
 (0)