hash.h: move object_id definition from cache.h
Our hashmap.h helpfully defines a sha1hash() function. But it cannot define a similar oidhash() without including all of cache.h, which itself wants to include hashmap.h! Let's break this circular dependency by moving the definition to hash.h, along with the remaining RAWSZ macros, etc. That will put them with the existing git_hash_algo definition. One alternative would be to move oidhash() into cache.h, but it's already quite bloated. We're better off moving things out than in. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 20, 2019 at 03:41 UTC
c0566d78aac1d5f8ff90c75f2d936487bb5a8d84
2 files changed
+24
-24
cache.h
-24
@@ -43,30 +43,6 @@ int git_deflate_end_gently(git_zstream *);
43
int git_deflate(git_zstream *, int flush);
44
unsigned long git_deflate_bound(git_zstream *, unsigned long);
45
46
-/* The length in bytes and in hex digits of an object name (SHA-1 value). */
47
-#define GIT_SHA1_RAWSZ 20
48
-#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
49
-/* The block size of SHA-1. */
50
-#define GIT_SHA1_BLKSZ 64
51
-
52
-/* The length in bytes and in hex digits of an object name (SHA-256 value). */
53
-#define GIT_SHA256_RAWSZ 32
54
-#define GIT_SHA256_HEXSZ (2 * GIT_SHA256_RAWSZ)
55
-/* The block size of SHA-256. */
56
-#define GIT_SHA256_BLKSZ 64
57
-
58
-/* The length in byte and in hex digits of the largest possible hash value. */
59
-#define GIT_MAX_RAWSZ GIT_SHA256_RAWSZ
60
-#define GIT_MAX_HEXSZ GIT_SHA256_HEXSZ
61
-/* The largest possible block size for any supported hash. */
62
-#define GIT_MAX_BLKSZ GIT_SHA256_BLKSZ
63
-
64
-struct object_id {
65
- unsigned char hash[GIT_MAX_RAWSZ];
66
-};
67
-
68
-#define the_hash_algo the_repository->hash_algo
69
-
46
#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
47
#define DTYPE(de) ((de)->d_type)
48
#else
hash.h
+24
@@ -139,4 +139,28 @@ static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
139
return p - hash_algos;
140
}
141
142
+/* The length in bytes and in hex digits of an object name (SHA-1 value). */
143
+#define GIT_SHA1_RAWSZ 20
144
+#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
145
+/* The block size of SHA-1. */
146
+#define GIT_SHA1_BLKSZ 64
147
+
148
+/* The length in bytes and in hex digits of an object name (SHA-256 value). */
149
+#define GIT_SHA256_RAWSZ 32
150
+#define GIT_SHA256_HEXSZ (2 * GIT_SHA256_RAWSZ)
151
+/* The block size of SHA-256. */
152
+#define GIT_SHA256_BLKSZ 64
153
+
154
+/* The length in byte and in hex digits of the largest possible hash value. */
155
+#define GIT_MAX_RAWSZ GIT_SHA256_RAWSZ
156
+#define GIT_MAX_HEXSZ GIT_SHA256_HEXSZ
157
+/* The largest possible block size for any supported hash. */
158
+#define GIT_MAX_BLKSZ GIT_SHA256_BLKSZ
159
+
160
+struct object_id {
161
+ unsigned char hash[GIT_MAX_RAWSZ];
162
+};
163
+
164
+#define the_hash_algo the_repository->hash_algo
165
+
166
#endif