]> git.ipfire.org Git - thirdparty/git.git/commit
hash: convert hashing context to a structure
authorPatrick Steinhardt <ps@pks.im>
Fri, 31 Jan 2025 12:55:28 +0000 (13:55 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 31 Jan 2025 18:06:10 +0000 (10:06 -0800)
commit52eef501e17078b369da571d7e6b72c7494bb779
tree706be7e5e77e83bb4265e7619adc0f9346719339
parent0cbcba54550b1ea108e977c24b835e07b96b1c0e
hash: convert hashing context to a structure

The `git_hash_context` is a union containing the different hash-specific
states for SHA1, its unsafe variant as well as SHA256. We know that only
one of these states will ever be in use at the same time because hash
contexts cannot be used for multiple different hashes at the same point
in time.

We're about to extend the structure though to keep track of the hash
algorithm used to initialize the context, which is impossible to do
while the context is a union. Refactor it to instead be a structure that
contains the union of context states.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
hash.h
object-file.c