Skip to content

Commit e1ccd7e

Browse files
bk2204gitster
authored andcommitted
sha1_file: only expose empty object constants through git_hash_algo
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba2df75 commit e1ccd7e

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

cache.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,22 +1013,6 @@ static inline void oidread(struct object_id *oid, const unsigned char *hash)
10131013
memcpy(oid->hash, hash, the_hash_algo->rawsz);
10141014
}
10151015

1016-
1017-
#define EMPTY_TREE_SHA1_HEX \
1018-
"4b825dc642cb6eb9a060e54bf8d69288fbee4904"
1019-
#define EMPTY_TREE_SHA1_BIN_LITERAL \
1020-
"\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60" \
1021-
"\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04"
1022-
extern const struct object_id empty_tree_oid;
1023-
#define EMPTY_TREE_SHA1_BIN (empty_tree_oid.hash)
1024-
1025-
#define EMPTY_BLOB_SHA1_HEX \
1026-
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"
1027-
#define EMPTY_BLOB_SHA1_BIN_LITERAL \
1028-
"\xe6\x9d\xe2\x9b\xb2\xd1\xd6\x43\x4b\x8b" \
1029-
"\x29\xae\x77\x5a\xd8\xc2\xe4\x8c\x53\x91"
1030-
extern const struct object_id empty_blob_oid;
1031-
10321016
static inline int is_empty_blob_sha1(const unsigned char *sha1)
10331017
{
10341018
return !hashcmp(sha1, the_hash_algo->empty_blob->hash);

sha1_file.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,21 @@
3535
/* The maximum size for an object header. */
3636
#define MAX_HEADER_LEN 32
3737

38+
39+
#define EMPTY_TREE_SHA1_BIN_LITERAL \
40+
"\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60" \
41+
"\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04"
42+
43+
#define EMPTY_BLOB_SHA1_BIN_LITERAL \
44+
"\xe6\x9d\xe2\x9b\xb2\xd1\xd6\x43\x4b\x8b" \
45+
"\x29\xae\x77\x5a\xd8\xc2\xe4\x8c\x53\x91"
46+
3847
const unsigned char null_sha1[GIT_MAX_RAWSZ];
3948
const struct object_id null_oid;
40-
const struct object_id empty_tree_oid = {
49+
static const struct object_id empty_tree_oid = {
4150
EMPTY_TREE_SHA1_BIN_LITERAL
4251
};
43-
const struct object_id empty_blob_oid = {
52+
static const struct object_id empty_blob_oid = {
4453
EMPTY_BLOB_SHA1_BIN_LITERAL
4554
};
4655

0 commit comments

Comments
 (0)