hex: default to the_hash_algo on zero algorithm value
commitb8505ecbf2b1e4ef27b9597fd113cb1679792b29
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 26 Apr 2021 01:03:00 +0000 (26 01:03 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 Apr 2021 07:31:39 +0000 (27 16:31 +0900)
tree4394a10a7d4c08e781ff062fd876e876fda48d0e
parent71b7672b674bc9a44fb41428804be428c2981046
hex: default to the_hash_algo on zero algorithm value

There are numerous places in the codebase where we assume we can
initialize data by zeroing all its bytes.  However, when we do that with
a struct object_id, it leaves the structure with a zero value for the
algorithm, which is invalid.

We could forbid this pattern and require that all struct object_id
instances be initialized using oidclr, but this seems burdensome and
it's unnatural to most C programmers.  Instead, if the algorithm is
zero, assume we wanted to use the default hash algorithm instead.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
hex.c