aboutsummaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-03-22 14:53:39 -0400
committerJunio C Hamano <gitster@pobox.com>2012-03-23 13:52:13 -0700
commitf8582cad8d11cae15e73fe5213b6180ee4b9fcce (patch)
tree245bdd3d26d92b1a44c7ac42d88141b3d623acfe /cache.h
parentcba595bd21fd0731e37898dbd6c5b55f65fd8aea (diff)
downloadgit-f8582cad8d11cae15e73fe5213b6180ee4b9fcce.tar.gz
git-f8582cad8d11cae15e73fe5213b6180ee4b9fcce.tar.xz
make is_empty_blob_sha1 available everywhere
The read-cache implementation defines this static function, but it is a generally useful concept in git. Let's give the empty blob the same treatment as the empty tree, providing both hex and binary forms of the sha1. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index e5e1aa4e1..528057480 100644
--- a/cache.h
+++ b/cache.h
@@ -708,6 +708,19 @@ static inline void hashclr(unsigned char *hash)
#define EMPTY_TREE_SHA1_BIN \
((const unsigned char *) EMPTY_TREE_SHA1_BIN_LITERAL)
+#define EMPTY_BLOB_SHA1_HEX \
+ "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"
+#define EMPTY_BLOB_SHA1_BIN_LITERAL \
+ "\xe6\x9d\xe2\x9b\xb2\xd1\xd6\x43\x4b\x8b" \
+ "\x29\xae\x77\x5a\xd8\xc2\xe4\x8c\x53\x91"
+#define EMPTY_BLOB_SHA1_BIN \
+ ((const unsigned char *) EMPTY_BLOB_SHA1_BIN_LITERAL)
+
+static inline int is_empty_blob_sha1(const unsigned char *sha1)
+{
+ return !hashcmp(sha1, EMPTY_BLOB_SHA1_BIN);
+}
+
int git_mkstemp(char *path, size_t n, const char *template);
int git_mkstemps(char *path, size_t n, const char *template, int suffix_len);