Skip to content

Commit 509f6f6

Browse files
bk2204gitster
authored andcommitted
cache: update object ID functions for the_hash_algo
Most of our code has been converted to use struct object_id for object IDs. However, there are some places that still have not, and there are a variety of places that compare equivalently sized hashes that are not object IDs. All of these hashes are artifacts of the internal hash algorithm in use, and when we switch to NewHash for object storage, all of these uses will also switch. Update the hashcpy, hashclr, and hashcmp functions to use the_hash_algo, since they are used in a variety of places to copy and manipulate buffers that need to move data into or out of struct object_id. This has the effect of making the corresponding oid* functions use the_hash_algo as well. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e333175 commit 509f6f6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cache.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ extern const struct object_id null_oid;
972972

973973
static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
974974
{
975-
return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
975+
return memcmp(sha1, sha2, the_hash_algo->rawsz);
976976
}
977977

978978
static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
@@ -992,7 +992,7 @@ static inline int is_null_oid(const struct object_id *oid)
992992

993993
static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
994994
{
995-
memcpy(sha_dst, sha_src, GIT_SHA1_RAWSZ);
995+
memcpy(sha_dst, sha_src, the_hash_algo->rawsz);
996996
}
997997

998998
static inline void oidcpy(struct object_id *dst, const struct object_id *src)
@@ -1009,7 +1009,7 @@ static inline struct object_id *oiddup(const struct object_id *src)
10091009

10101010
static inline void hashclr(unsigned char *hash)
10111011
{
1012-
memset(hash, 0, GIT_SHA1_RAWSZ);
1012+
memset(hash, 0, the_hash_algo->rawsz);
10131013
}
10141014

10151015
static inline void oidclr(struct object_id *oid)

0 commit comments

Comments
 (0)