diff options
author | brian m. carlson <sandals@crustytoothpaste.net> | 2018-03-12 02:27:39 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-03-14 09:23:49 -0700 |
commit | 17e65451e305b7501fddec35125bf5d39a4cdcac (patch) | |
tree | ffd070759d814151fd56faebfa4a9b951eeaa240 /sha1_file.c | |
parent | sha1_file: convert read_loose_object to use struct object_id (diff) | |
download | tgif-17e65451e305b7501fddec35125bf5d39a4cdcac.tar.xz |
sha1_file: convert check_sha1_signature to struct object_id
Convert this function to take a pointer to struct object_id and rename
it check_object_signature. Introduce temporaries to convert the return
values of lookup_replace_object and lookup_replace_object_extended into
struct object_id.
The temporaries are needed because in order to convert
lookup_replace_object, open_istream needs to be converted, and
open_istream needs check_sha1_signature to be converted, causing a loop
of dependencies. The temporaries will be removed in a future patch.
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 | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sha1_file.c b/sha1_file.c index 5081d585a2..e4cb840661 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -784,8 +784,8 @@ void *xmmap(void *start, size_t length, * With "map" == NULL, try reading the object named with "sha1" using * the streaming interface and rehash it to do the same. */ -int check_sha1_signature(const unsigned char *sha1, void *map, - unsigned long size, const char *type) +int check_object_signature(const struct object_id *oid, void *map, + unsigned long size, const char *type) { struct object_id real_oid; enum object_type obj_type; @@ -796,10 +796,10 @@ int check_sha1_signature(const unsigned char *sha1, void *map, if (map) { hash_object_file(map, size, type, &real_oid); - return hashcmp(sha1, real_oid.hash) ? -1 : 0; + return oidcmp(oid, &real_oid) ? -1 : 0; } - st = open_istream(sha1, &obj_type, &size, NULL); + st = open_istream(oid->hash, &obj_type, &size, NULL); if (!st) return -1; @@ -823,7 +823,7 @@ int check_sha1_signature(const unsigned char *sha1, void *map, } the_hash_algo->final_fn(real_oid.hash, &c); close_istream(st); - return hashcmp(sha1, real_oid.hash) ? -1 : 0; + return oidcmp(oid, &real_oid) ? -1 : 0; } int git_open_cloexec(const char *name, int flags) @@ -2217,7 +2217,7 @@ int read_loose_object(const char *path, git_inflate_end(&stream); goto out; } - if (check_sha1_signature(expected_oid->hash, *contents, + if (check_object_signature(expected_oid, *contents, *size, type_name(*type))) { error("sha1 mismatch for %s (expected %s)", path, oid_to_hex(expected_oid)); |