From 9005b5bb72df521670db03eefeafe53c0a81f9a5 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Sat, 7 Feb 2026 20:04:36 +0000 Subject: hash: add a function to look up hash algo structs In C, it's easy for us to look up a hash algorithm structure by its offset by simply indexing the hash_algos array. However, in Rust, we sometimes need a pointer to pass to a C function, but we have our own hash algorithm abstraction. To get one from the other, let's provide a simple function that looks up the C structure from the offset and expose it in Rust. Signed-off-by: brian m. carlson Signed-off-by: Junio C Hamano --- hash.h | 1 + 1 file changed, 1 insertion(+) (limited to 'hash.h') diff --git a/hash.h b/hash.h index 99c9c2a0a8..709d7585a5 100644 --- a/hash.h +++ b/hash.h @@ -340,6 +340,7 @@ static inline void git_hash_final_oid(struct object_id *oid, struct git_hash_ctx ctx->algop->final_oid_fn(oid, ctx); } +const struct git_hash_algo *hash_algo_ptr_by_number(uint32_t algo); /* * Return a GIT_HASH_* constant based on the name. Returns GIT_HASH_UNKNOWN if * the name doesn't match a known algorithm. -- cgit v1.3-5-g45d5