Skip to content

Commit 095261a

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 867386d commit 095261a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hash.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,15 @@ static inline void oidclr(struct object_id *oid)
7373
oid->algo = hash_algo_by_ptr(the_hash_algo);
7474
}
7575

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+
7682
static inline void oidread(struct object_id *oid, const unsigned char *hash)
7783
{
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);
8085
}
8186

8287
static inline int is_empty_blob_sha1(const unsigned char *sha1)

0 commit comments

Comments
 (0)