From 8576fde6cb4013a41d162e33f7a0046a5ea6801e Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Wed, 31 Aug 2016 16:27:18 -0700 Subject: cache: add empty_tree_oid object and helper function Similar to is_null_oid(), and is_empty_blob_sha1() add an empty_tree_oid along with helper function is_empty_tree_oid(). For completeness, also add an "is_empty_tree_sha1()", "is_empty_blob_sha1()", "is_empty_tree_oid()" and "is_empty_blob_oid()" helpers. To ensure we only get one singleton, implement EMPTY_BLOB_SHA1_BIN as simply getting the hash of empty_blob_oid structure. Signed-off-by: Jacob Keller Signed-off-by: Junio C Hamano --- sha1_file.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sha1_file.c') diff --git a/sha1_file.c b/sha1_file.c index 02940f192..5b8553d69 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -38,6 +38,12 @@ static inline uintmax_t sz_fmt(size_t s) { return s; } const unsigned char null_sha1[20]; const struct object_id null_oid; +const struct object_id empty_tree_oid = { + EMPTY_TREE_SHA1_BIN_LITERAL +}; +const struct object_id empty_blob_oid = { + EMPTY_BLOB_SHA1_BIN_LITERAL +}; /* * This is meant to hold a *small* number of objects that you would -- cgit v1.2.1