Skip to content

Commit c0566d7

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e465e7c commit c0566d7

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

cache.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,6 @@ int git_deflate_end_gently(git_zstream *);
4343
int git_deflate(git_zstream *, int flush);
4444
unsigned long git_deflate_bound(git_zstream *, unsigned long);
4545

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-
7046
#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
7147
#define DTYPE(de) ((de)->d_type)
7248
#else

hash.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,28 @@ static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
139139
return p - hash_algos;
140140
}
141141

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+
142166
#endif

0 commit comments

Comments
 (0)