aboutsummaryrefslogtreecommitdiffstats
path: root/object-file.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2023-10-01 21:40:29 -0500
committerJunio C Hamano <gitster@pobox.com>2023-10-02 14:57:40 -0700
commit8d691757b8fcbe9b7898a5d1dcb37b198a8c60e1 (patch)
tree296397850f8359824b68ee06873fcad15d6110f9 /object-file.c
parentefed687edcaa272601e0f4e192db368972daa7ac (diff)
downloadgit-8d691757b8fcbe9b7898a5d1dcb37b198a8c60e1.tar.gz
object-file: handle compat objects in check_object_signature
Update check_object_signature to find the hash algorithm the exising signature uses, and to use the same hash algorithm when recomputing it to check the signature is valid. This will be useful when teaching git ls-tree to display objects encoded with the compat hash algorithm. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'object-file.c')
-rw-r--r--object-file.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/object-file.c b/object-file.c
index b2d43d0098..5fa4b14bae 100644
--- a/object-file.c
+++ b/object-file.c
@@ -1094,9 +1094,11 @@ int check_object_signature(struct repository *r, const struct object_id *oid,
void *buf, unsigned long size,
enum object_type type)
{
+ const struct git_hash_algo *algo =
+ oid->algo ? &hash_algos[oid->algo] : r->hash_algo;
struct object_id real_oid;
- hash_object_file(r->hash_algo, buf, size, type, &real_oid);
+ hash_object_file(algo, buf, size, type, &real_oid);
return !oideq(oid, &real_oid) ? -1 : 0;
}