From 02f0547eaaeeec3446b77a29593f9233cf94d626 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Mon, 12 Mar 2018 02:27:52 +0000 Subject: sha1_file: convert read_object_with_reference to object_id Convert read_object_with_reference to take pointers to struct object_id. Update the internals of the function accordingly. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- sha1_file.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sha1_file.c') diff --git a/sha1_file.c b/sha1_file.c index e1292c11fd..e2b8e7694e 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1399,29 +1399,29 @@ void *read_sha1_file_extended(const unsigned char *sha1, return NULL; } -void *read_object_with_reference(const unsigned char *sha1, +void *read_object_with_reference(const struct object_id *oid, const char *required_type_name, unsigned long *size, - unsigned char *actual_sha1_return) + struct object_id *actual_oid_return) { enum object_type type, required_type; void *buffer; unsigned long isize; - unsigned char actual_sha1[20]; + struct object_id actual_oid; required_type = type_from_string(required_type_name); - hashcpy(actual_sha1, sha1); + oidcpy(&actual_oid, oid); while (1) { int ref_length = -1; const char *ref_type = NULL; - buffer = read_sha1_file(actual_sha1, &type, &isize); + buffer = read_sha1_file(actual_oid.hash, &type, &isize); if (!buffer) return NULL; if (type == required_type) { *size = isize; - if (actual_sha1_return) - hashcpy(actual_sha1_return, actual_sha1); + if (actual_oid_return) + oidcpy(actual_oid_return, &actual_oid); return buffer; } /* Handle references */ @@ -1435,15 +1435,15 @@ void *read_object_with_reference(const unsigned char *sha1, } ref_length = strlen(ref_type); - if (ref_length + 40 > isize || + if (ref_length + GIT_SHA1_HEXSZ > isize || memcmp(buffer, ref_type, ref_length) || - get_sha1_hex((char *) buffer + ref_length, actual_sha1)) { + get_oid_hex((char *) buffer + ref_length, &actual_oid)) { free(buffer); return NULL; } free(buffer); /* Now we have the ID of the referred-to object in - * actual_sha1. Check again. */ + * actual_oid. Check again. */ } } -- cgit v1.2.3