diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2018-03-12 03:27:52 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-03-14 17:23:50 +0100 |
commit | 02f0547eaaeeec3446b77a29593f9233cf94d626 (patch) | |
tree | 286f46ad2d534800155bf94a4c2bddb455fcac35 /sha1_file.c | |
parent | tree-walk: convert tree entry functions to object_id (diff) | |
download | git-02f0547eaaeeec3446b77a29593f9233cf94d626.tar.xz git-02f0547eaaeeec3446b77a29593f9233cf94d626.zip |
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 <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 20 |
1 files changed, 10 insertions, 10 deletions
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. */ } } |