Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2018-05-02 03:25:29 +0300
committerJunio C Hamano <gitster@pobox.com>2018-05-02 07:59:48 +0300
commit69d124255ede771ff8162652762406c55ba491c0 (patch)
tree3249ee68c31622d295b8086a435acffe8441d045 /cache.h
parentfe0a9eaf31dd0c349ae4308498c33a5c3794b293 (diff)
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>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index bbaf5c349a..4bca177cf3 100644
--- a/cache.h
+++ b/cache.h
@@ -1008,6 +1008,11 @@ static inline void oidclr(struct object_id *oid)
memset(oid->hash, 0, GIT_MAX_RAWSZ);
}
+static inline void oidread(struct object_id *oid, const unsigned char *hash)
+{
+ memcpy(oid->hash, hash, the_hash_algo->rawsz);
+}
+
#define EMPTY_TREE_SHA1_HEX \
"4b825dc642cb6eb9a060e54bf8d69288fbee4904"