cache: add a function to read an object ID from a buffer

In various places throughout the codebase, we need to read data into a
struct object_id from a pack or other unsigned char buffer.  Add an
inline function that does this based on the current hash algorithm in
use, and use it in several places.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson
2018-05-02 00:25:29 +00:00
committed by Junio C Hamano
parent fe0a9eaf31
commit 69d124255e
3 changed files with 7 additions and 2 deletions

View File

@ -523,7 +523,7 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
if (0 <= it->entry_count) {
if (size < rawsz)
goto free_return;
memcpy(it->oid.hash, (const unsigned char*)buf, rawsz);
oidread(&it->oid, (const unsigned char *)buf);
buf += rawsz;
size -= rawsz;
}