sha1_file: only expose empty object constants through git_hash_algo
authorbrian m. carlson <sandals@crustytoothpaste.net>
Wed, 2 May 2018 00:26:07 +0000 (00:26 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 May 2018 04:59:53 +0000 (13:59 +0900)
There really isn't any case in which we want to expose the constants for
empty trees and blobs outside of using the hash algorithm abstraction.
Make these constants static and stop exposing the defines in cache.h.
Remove the constants which are no longer in use.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
sha1_file.c
diff --git a/cache.h b/cache.h
index 14690c84a277a0ab5cbdab3742f9ef909b8da00c..71b3c1b15b98ce227ac6b957be59a1f5a877dd7d 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1013,22 +1013,6 @@ static inline void oidread(struct object_id *oid, const unsigned char *hash)
        memcpy(oid->hash, hash, the_hash_algo->rawsz);
 }
 
        memcpy(oid->hash, hash, the_hash_algo->rawsz);
 }
 
-
-#define EMPTY_TREE_SHA1_HEX \
-       "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
-#define EMPTY_TREE_SHA1_BIN_LITERAL \
-        "\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60" \
-        "\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04"
-extern const struct object_id empty_tree_oid;
-#define EMPTY_TREE_SHA1_BIN (empty_tree_oid.hash)
-
-#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"
-extern const struct object_id empty_blob_oid;
-
 static inline int is_empty_blob_sha1(const unsigned char *sha1)
 {
        return !hashcmp(sha1, the_hash_algo->empty_blob->hash);
 static inline int is_empty_blob_sha1(const unsigned char *sha1)
 {
        return !hashcmp(sha1, the_hash_algo->empty_blob->hash);
index 4acbf8ee0839fef167e71ee7cf4199fd99249140..bf6c8da3ffb2867ea4a326ad08b49008943c0a9a 100644 (file)
 /* The maximum size for an object header. */
 #define MAX_HEADER_LEN 32
 
 /* The maximum size for an object header. */
 #define MAX_HEADER_LEN 32
 
+
+#define EMPTY_TREE_SHA1_BIN_LITERAL \
+        "\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60" \
+        "\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04"
+
+#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"
+
 const unsigned char null_sha1[GIT_MAX_RAWSZ];
 const struct object_id null_oid;
 const unsigned char null_sha1[GIT_MAX_RAWSZ];
 const struct object_id null_oid;
-const struct object_id empty_tree_oid = {
+static const struct object_id empty_tree_oid = {
        EMPTY_TREE_SHA1_BIN_LITERAL
 };
        EMPTY_TREE_SHA1_BIN_LITERAL
 };
-const struct object_id empty_blob_oid = {
+static const struct object_id empty_blob_oid = {
        EMPTY_BLOB_SHA1_BIN_LITERAL
 };
 
        EMPTY_BLOB_SHA1_BIN_LITERAL
 };