Skip to content

Commit 8d69175

Browse files
ebiedermgitster
authored andcommitted
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" <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent efed687 commit 8d69175

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

object-file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,9 +1094,11 @@ int check_object_signature(struct repository *r, const struct object_id *oid,
10941094
void *buf, unsigned long size,
10951095
enum object_type type)
10961096
{
1097+
const struct git_hash_algo *algo =
1098+
oid->algo ? &hash_algos[oid->algo] : r->hash_algo;
10971099
struct object_id real_oid;
10981100

1099-
hash_object_file(r->hash_algo, buf, size, type, &real_oid);
1101+
hash_object_file(algo, buf, size, type, &real_oid);
11001102

11011103
return !oideq(oid, &real_oid) ? -1 : 0;
11021104
}

0 commit comments

Comments
 (0)