(This series is based on my 'tb/sha1-unsafe-helper', which I sent to the list here[1].) This series implements an idea discussed in [2] which suggests that we introduce a way to access a wrapped version of a 'struct git_hash_algo' which represents the unsafe variant of that algorithm, rather than having individual unsafe_ functions (like unsafe_init_fn() versus init_fn(), etc.). This approach is relatively straightforward to implement, and removes a significant deficiency in the original implementation of unsafe/non-cryptographic hash functions by making it impossible to switch between safe- and unsafe variants of hash functions. It also cleans up the sha1-unsafe test helper's implementation by removing a large number of "if (unsafe)"-style conditionals. The series is laid out as follows: * The first two patches prepare the hashfile API for the upcoming change: csum-file: store the hash algorithm as a struct field csum-file.c: extract algop from hashfile_checksum_valid() * The next patch implements the new 'unsafe_hash_algo()' function at the heart of this series' approach: hash.h: introduce `unsafe_hash_algo()` * The next two patches convert existing callers to use the new 'unsafe_hash_algo()' function, instead of switching between safe and unsafe_ variants of individual functions: csum-file.c: use unsafe_hash_algo() t/helper/test-hash.c: use unsafe_hash_algo() * The final patch drops the unsafe_ function variants following all callers being converted to use the new pattern: hash.h: drop unsafe_ function variants Thanks in advance for your review! [1]: https://lore.kernel.org/git/cover.1730833506.git.me@xxxxxxxxxxxx/ [2]: https://lore.kernel.org/git/20241107013915.GA961214@xxxxxxxxxxxxxxxxxxxxxxx/ Taylor Blau (6): csum-file: store the hash algorithm as a struct field csum-file.c: extract algop from hashfile_checksum_valid() hash.h: introduce `unsafe_hash_algo()` csum-file.c: use unsafe_hash_algo() t/helper/test-hash.c: use unsafe_hash_algo() hash.h: drop unsafe_ function variants csum-file.c | 33 ++++++++++++++++++--------------- csum-file.h | 1 + hash.h | 20 +++++--------------- object-file.c | 41 ++++++++++++++++++++++++++--------------- t/helper/test-hash.c | 17 +++++------------ 5 files changed, 55 insertions(+), 57 deletions(-) base-commit: d8c1fc78b57e02a140b5c363caaa14c2dc2bb274 -- 2.47.0.237.gc601277f4c4