cache: add a function to read an OID of a specific algorithm
Currently, we always read a object ID of the current algorithm with oidread. However, once we start converting objects, we'll need to consider what happens when we want to read an object ID of a specific algorithm, such as the compatibility algorithm. To make this easier, let's define oidread_algop, which specifies which algorithm we should use for our object ID, and define oidread in terms of it. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Oct 1, 2023 at 21:40 UTC
095261a18d91cf47e8e8ef3b55f5e88e52ffc85f
1 file changed
+7
-2
hash.h
+7
-2
@@ -73,10 +73,15 @@ static inline void oidclr(struct object_id *oid)
73
oid->algo = hash_algo_by_ptr(the_hash_algo);
74
}
75
76
+static inline void oidread_algop(struct object_id *oid, const unsigned char *hash, const struct git_hash_algo *algop)
77
+{
78
+ memcpy(oid->hash, hash, algop->rawsz);
79
+ oid->algo = hash_algo_by_ptr(algop);
80
+}
81
+
82
static inline void oidread(struct object_id *oid, const unsigned char *hash)
83
{
78
- memcpy(oid->hash, hash, the_hash_algo->rawsz);
79
- oid->algo = hash_algo_by_ptr(the_hash_algo);
84
+ oidread_algop(oid, hash, the_hash_algo);
85
}
86
87
static inline int is_empty_blob_sha1(const unsigned char *sha1)