hash-ll.h: split out of hash.h to remove dependency on repository.h

hash.h depends upon and includes repository.h, due to the definition and use of the_hash_algo (defined as the_repository->hash_algo). However, most headers trying to include hash.h are only interested in the layout of the structs like object_id. Move the parts of hash.h that do not depend upon repository.h into a new file hash-ll.h (the "low level" parts of hash.h), and adjust other files to use this new header where the convenience inline functions aren't needed. This allows hash.h and object.h to be fairly small, minimal headers. It also exposes a lot of hidden dependencies on both path.h (which was brought in by repository.h) and repository.h (which was previously implicitly brought in by object.h), so also adjust other files to be more explicit about what they depend upon. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Apr 22, 2023 at 20:17 UTC d1cbe1e6d8a9cab2b4ffe8a17d34db214dce1e49
109 files changed +398 -292
alloc.c
+1
@@ -13,6 +13,7 @@
13 #include "blob.h"
14 #include "tree.h"
15 #include "commit.h"
16 +#include "repository.h"
17 #include "tag.h"
18 #include "alloc.h"
19
apply.h
+1 -1
@@ -1,7 +1,7 @@
1 #ifndef APPLY_H
2 #define APPLY_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5 #include "lockfile.h"
6 #include "string-list.h"
7 #include "strmap.h"
branch.c
+1
@@ -9,6 +9,7 @@
9 #include "refs.h"
10 #include "refspec.h"
11 #include "remote.h"
12 +#include "repository.h"
13 #include "sequencer.h"
14 #include "commit.h"
15 #include "worktree.h"
builtin/apply.c
+1
@@ -2,6 +2,7 @@
2 #include "builtin.h"
3 #include "gettext.h"
4 #include "parse-options.h"
5 +#include "repository.h"
6 #include "apply.h"
7
8 static const char * const apply_usage[] = {
builtin/archive.c
+1
@@ -9,6 +9,7 @@
9 #include "transport.h"
10 #include "parse-options.h"
11 #include "pkt-line.h"
12 +#include "repository.h"
13 #include "sideband.h"
14
15 static void create_output_file(const char *output_file)
builtin/bundle.c
+1
@@ -5,6 +5,7 @@
5 #include "strvec.h"
6 #include "parse-options.h"
7 #include "pkt-line.h"
8 +#include "repository.h"
9 #include "cache.h"
10 #include "bundle.h"
11
builtin/check-attr.c
+1
@@ -7,6 +7,7 @@
7 #include "gettext.h"
8 #include "object-name.h"
9 #include "quote.h"
10 +#include "repository.h"
11 #include "setup.h"
12 #include "parse-options.h"
13 #include "write-or-die.h"
builtin/check-ignore.c
+1
@@ -7,6 +7,7 @@
7 #include "quote.h"
8 #include "pathspec.h"
9 #include "parse-options.h"
10 +#include "repository.h"
11 #include "submodule.h"
12 #include "write-or-die.h"
13
builtin/checkout-index.c
+1
@@ -11,6 +11,7 @@
11 #include "gettext.h"
12 #include "lockfile.h"
13 #include "quote.h"
14 +#include "repository.h"
15 #include "cache-tree.h"
16 #include "parse-options.h"
17 #include "entry.h"
builtin/clean.c
+1
@@ -14,6 +14,7 @@
14 #include "dir.h"
15 #include "gettext.h"
16 #include "parse-options.h"
17 +#include "repository.h"
18 #include "setup.h"
19 #include "string-list.h"
20 #include "quote.h"
builtin/config.c
+1
@@ -9,6 +9,7 @@
9 #include "ident.h"
10 #include "parse-options.h"
11 #include "urlmatch.h"
12 +#include "path.h"
13 #include "quote.h"
14 #include "setup.h"
15 #include "worktree.h"
builtin/credential-cache.c
+1
@@ -1,6 +1,7 @@
1 #include "builtin.h"
2 #include "gettext.h"
3 #include "parse-options.h"
4 +#include "path.h"
5 #include "wrapper.h"
6 #include "write-or-die.h"
7
builtin/credential-store.c
+1
@@ -3,6 +3,7 @@
3 #include "gettext.h"
4 #include "lockfile.h"
5 #include "credential.h"
6 +#include "path.h"
7 #include "string-list.h"
8 #include "parse-options.h"
9 #include "write-or-die.h"
builtin/for-each-repo.c
+2
@@ -3,6 +3,8 @@
3 #include "builtin.h"
4 #include "gettext.h"
5 #include "parse-options.h"
6 +#include "path.h"
7 +#include "repository.h"
8 #include "run-command.h"
9 #include "string-list.h"
10
builtin/help.c
+1
@@ -8,6 +8,7 @@
8 #include "gettext.h"
9 #include "pager.h"
10 #include "parse-options.h"
11 +#include "path.h"
12 #include "run-command.h"
13 #include "config-list.h"
14 #include "help.h"
builtin/init-db.c
+1
@@ -14,6 +14,7 @@
14 #include "exec-cmd.h"
15 #include "object-file.h"
16 #include "parse-options.h"
17 +#include "path.h"
18 #include "setup.h"
19 #include "worktree.h"
20 #include "wrapper.h"
builtin/merge-index.c
+1
@@ -1,6 +1,7 @@
1 #define USE_THE_INDEX_VARIABLE
2 #include "builtin.h"
3 #include "hex.h"
4 +#include "repository.h"
5 #include "run-command.h"
6
7 static const char *pgm;
builtin/merge-recursive.c
+2
@@ -3,9 +3,11 @@
3 #include "advice.h"
4 #include "commit.h"
5 #include "gettext.h"
6 +#include "hash.h"
7 #include "tag.h"
8 #include "merge-recursive.h"
9 #include "object-name.h"
10 +#include "repository.h"
11 #include "xdiff-interface.h"
12
13 static const char builtin_merge_recursive_usage[] =
builtin/mv.c
+1
@@ -18,6 +18,7 @@
18 #include "cache-tree.h"
19 #include "string-list.h"
20 #include "parse-options.h"
21 +#include "repository.h"
22 #include "setup.h"
23 #include "submodule.h"
24 #include "entry.h"
builtin/push.c
+1
@@ -15,6 +15,7 @@
15 #include "transport.h"
16 #include "parse-options.h"
17 #include "pkt-line.h"
18 +#include "repository.h"
19 #include "submodule.h"
20 #include "submodule-config.h"
21 #include "send-pack.h"
builtin/read-tree.c
+1
@@ -19,6 +19,7 @@
19 #include "dir.h"
20 #include "builtin.h"
21 #include "parse-options.h"
22 +#include "repository.h"
23 #include "resolve-undo.h"
24 #include "setup.h"
25 #include "submodule.h"
builtin/rerere.c
+1
@@ -4,6 +4,7 @@
4 #include "dir.h"
5 #include "gettext.h"
6 #include "parse-options.h"
7 +#include "repository.h"
8 #include "string-list.h"
9 #include "rerere.h"
10 #include "wrapper.h"
builtin/rm.c
+2
@@ -12,9 +12,11 @@
12 #include "dir.h"
13 #include "cache-tree.h"
14 #include "gettext.h"
15 +#include "hash.h"
16 #include "tree-walk.h"
17 #include "object-name.h"
18 #include "parse-options.h"
19 +#include "repository.h"
20 #include "string-list.h"
21 #include "setup.h"
22 #include "submodule.h"
builtin/show-branch.c
+2
@@ -2,6 +2,7 @@
2 #include "config.h"
3 #include "environment.h"
4 #include "gettext.h"
5 +#include "hash.h"
6 #include "hex.h"
7 #include "pretty.h"
8 #include "refs.h"
@@ -10,6 +11,7 @@
11 #include "strvec.h"
12 #include "object-name.h"
13 #include "parse-options.h"
14 +#include "repository.h"
15 #include "dir.h"
16 #include "commit-slab.h"
17 #include "date.h"
builtin/show-index.c
+2
@@ -1,9 +1,11 @@
1 #include "builtin.h"
2 #include "cache.h"
3 #include "gettext.h"
4 +#include "hash.h"
5 #include "hex.h"
6 #include "pack.h"
7 #include "parse-options.h"
8 +#include "repository.h"
9
10 static const char *const show_index_usage[] = {
11 "git show-index [--object-format=<hash-algorithm>]",
builtin/update-index.c
+2
@@ -9,6 +9,7 @@
9 #include "config.h"
10 #include "environment.h"
11 #include "gettext.h"
12 +#include "hash.h"
13 #include "hex.h"
14 #include "lockfile.h"
15 #include "quote.h"
@@ -21,6 +22,7 @@
22 #include "parse-options.h"
23 #include "pathspec.h"
24 #include "dir.h"
25 +#include "repository.h"
26 #include "setup.h"
27 #include "split-index.h"
28 #include "symlinks.h"
builtin/update-ref.c
+2
@@ -1,11 +1,13 @@
1 #include "cache.h"
2 #include "config.h"
3 #include "gettext.h"
4 +#include "hash.h"
5 #include "refs.h"
6 #include "builtin.h"
7 #include "object-name.h"
8 #include "parse-options.h"
9 #include "quote.h"
10 +#include "repository.h"
11 #include "strvec.h"
12
13 static const char * const git_update_ref_usage[] = {
builtin/upload-archive.c
+1
@@ -6,6 +6,7 @@
6 #include "archive.h"
7 #include "pkt-line.h"
8 #include "sideband.h"
9 +#include "repository.h"
10 #include "run-command.h"
11 #include "strvec.h"
12
builtin/worktree.c
+1
@@ -14,6 +14,7 @@
14 #include "strvec.h"
15 #include "branch.h"
16 #include "refs.h"
17 +#include "repository.h"
18 #include "run-command.h"
19 #include "hook.h"
20 #include "sigchain.h"
checkout.c
+1
@@ -2,6 +2,7 @@
2 #include "object-name.h"
3 #include "remote.h"
4 #include "refspec.h"
5 +#include "repository.h"
6 #include "checkout.h"
7 #include "config.h"
8 #include "strbuf.h"
checkout.h
+1 -1
@@ -1,7 +1,7 @@
1 #ifndef CHECKOUT_H
2 #define CHECKOUT_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5
6 /*
7 * Check if the branch name uniquely matches a branch name on a remote
chunk-format.c
+1
@@ -3,6 +3,7 @@
3 #include "chunk-format.h"
4 #include "csum-file.h"
5 #include "gettext.h"
6 +#include "hash.h"
7 #include "trace2.h"
8
9 /*
chunk-format.h
+1 -1
@@ -1,7 +1,7 @@
1 #ifndef CHUNK_FORMAT_H
2 #define CHUNK_FORMAT_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5
6 struct hashfile;
7 struct chunkfile;
common-main.c
+1
@@ -2,6 +2,7 @@
2 #include "exec-cmd.h"
3 #include "gettext.h"
4 #include "attr.h"
5 +#include "repository.h"
6 #include "setup.h"
7 #include "strbuf.h"
8 #include "trace2.h"
compat/fsmonitor/fsm-ipc-darwin.c
+1
@@ -1,6 +1,7 @@
1 #include "cache.h"
2 #include "config.h"
3 #include "hex.h"
4 +#include "repository.h"
5 #include "strbuf.h"
6 #include "fsmonitor.h"
7 #include "fsmonitor-ipc.h"
compat/fsmonitor/fsm-ipc-win32.c
+1
@@ -1,6 +1,7 @@
1 #include "git-compat-util.h"
2 #include "config.h"
3 #include "fsmonitor-ipc.h"
4 +#include "path.h"
5
6 const char *fsmonitor_ipc__get_path(struct repository *r) {
7 static char *ret;
compat/precompose_utf8.c
+1
@@ -9,6 +9,7 @@
9 #include "config.h"
10 #include "environment.h"
11 #include "gettext.h"
12 +#include "path.h"
13 #include "utf8.h"
14 #include "precompose_utf8.h"
15
compat/win32/trace2_win32_process_info.c
+1
@@ -1,5 +1,6 @@
1 #include "../../cache.h"
2 #include "../../json-writer.h"
3 +#include "../../repository.h"
4 #include "../../trace2.h"
5 #include "lazyload.h"
6 #include <Psapi.h>
convert.h
+1 -1
@@ -4,7 +4,7 @@
4 #ifndef CONVERT_H
5 #define CONVERT_H
6
7 -#include "hash.h"
7 +#include "hash-ll.h"
8 #include "string-list.h"
9
10 struct index_state;
copy.c
+1
@@ -1,5 +1,6 @@
1 #include "cache.h"
2 #include "copy.h"
3 +#include "path.h"
4 #include "wrapper.h"
5
6 int copy_fd(int ifd, int ofd)
csum-file.c
+1
@@ -10,6 +10,7 @@
10 #include "git-compat-util.h"
11 #include "progress.h"
12 #include "csum-file.h"
13 +#include "hash.h"
14 #include "wrapper.h"
15
16 static void verify_buffer_or_die(struct hashfile *f,
csum-file.h
+1 -1
@@ -1,7 +1,7 @@
1 #ifndef CSUM_FILE_H
2 #define CSUM_FILE_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5 #include "write-or-die.h"
6
7 struct progress;
daemon.c
+1
@@ -3,6 +3,7 @@
3 #include "alloc.h"
4 #include "config.h"
5 #include "environment.h"
6 +#include "path.h"
7 #include "pkt-line.h"
8 #include "protocol.h"
9 #include "run-command.h"
diffcore.h
+1 -1
@@ -4,7 +4,7 @@
4 #ifndef DIFFCORE_H
5 #define DIFFCORE_H
6
7 -#include "hash.h"
7 +#include "hash-ll.h"
8
9 struct diff_options;
10 struct mem_pool;
editor.c
+1
@@ -6,6 +6,7 @@
6 #include "environment.h"
7 #include "gettext.h"
8 #include "pager.h"
9 +#include "path.h"
10 #include "strbuf.h"
11 #include "strvec.h"
12 #include "run-command.h"
exec-cmd.c
+1
@@ -3,6 +3,7 @@
3 #include "environment.h"
4 #include "exec-cmd.h"
5 #include "gettext.h"
6 +#include "path.h"
7 #include "quote.h"
8 #include "strvec.h"
9 #include "trace.h"
fsmonitor-ipc.c
+1
@@ -3,6 +3,7 @@
3 #include "gettext.h"
4 #include "simple-ipc.h"
5 #include "fsmonitor-ipc.h"
6 +#include "repository.h"
7 #include "run-command.h"
8 #include "strbuf.h"
9 #include "trace2.h"
gpg-interface.c
+1
@@ -7,6 +7,7 @@
7 #include "dir.h"
8 #include "ident.h"
9 #include "gpg-interface.h"
10 +#include "path.h"
11 #include "sigchain.h"
12 #include "tempfile.h"
13 #include "alias.h"
hash-ll.h new
+276
@@ -0,0 +1,276 @@
1 +#ifndef HASH_LL_H
2 +#define HASH_LL_H
3 +
4 +#if defined(SHA1_APPLE)
5 +#include <CommonCrypto/CommonDigest.h>
6 +#elif defined(SHA1_OPENSSL)
7 +#include <openssl/sha.h>
8 +#elif defined(SHA1_DC)
9 +#include "sha1dc_git.h"
10 +#else /* SHA1_BLK */
11 +#include "block-sha1/sha1.h"
12 +#endif
13 +
14 +#if defined(SHA256_NETTLE)
15 +#include "sha256/nettle.h"
16 +#elif defined(SHA256_GCRYPT)
17 +#define SHA256_NEEDS_CLONE_HELPER
18 +#include "sha256/gcrypt.h"
19 +#elif defined(SHA256_OPENSSL)
20 +#include <openssl/sha.h>
21 +#else
22 +#include "sha256/block/sha256.h"
23 +#endif
24 +
25 +#ifndef platform_SHA_CTX
26 +/*
27 + * platform's underlying implementation of SHA-1; could be OpenSSL,
28 + * blk_SHA, Apple CommonCrypto, etc... Note that the relevant
29 + * SHA-1 header may have already defined platform_SHA_CTX for our
30 + * own implementations like block-sha1, so we list
31 + * the default for OpenSSL compatible SHA-1 implementations here.
32 + */
33 +#define platform_SHA_CTX SHA_CTX
34 +#define platform_SHA1_Init SHA1_Init
35 +#define platform_SHA1_Update SHA1_Update
36 +#define platform_SHA1_Final SHA1_Final
37 +#endif
38 +
39 +#define git_SHA_CTX platform_SHA_CTX
40 +#define git_SHA1_Init platform_SHA1_Init
41 +#define git_SHA1_Update platform_SHA1_Update
42 +#define git_SHA1_Final platform_SHA1_Final
43 +
44 +#ifndef platform_SHA256_CTX
45 +#define platform_SHA256_CTX SHA256_CTX
46 +#define platform_SHA256_Init SHA256_Init
47 +#define platform_SHA256_Update SHA256_Update
48 +#define platform_SHA256_Final SHA256_Final
49 +#endif
50 +
51 +#define git_SHA256_CTX platform_SHA256_CTX
52 +#define git_SHA256_Init platform_SHA256_Init
53 +#define git_SHA256_Update platform_SHA256_Update
54 +#define git_SHA256_Final platform_SHA256_Final
55 +
56 +#ifdef platform_SHA256_Clone
57 +#define git_SHA256_Clone platform_SHA256_Clone
58 +#endif
59 +
60 +#ifdef SHA1_MAX_BLOCK_SIZE
61 +#include "compat/sha1-chunked.h"
62 +#undef git_SHA1_Update
63 +#define git_SHA1_Update git_SHA1_Update_Chunked
64 +#endif
65 +
66 +static inline void git_SHA1_Clone(git_SHA_CTX *dst, const git_SHA_CTX *src)
67 +{
68 + memcpy(dst, src, sizeof(*dst));
69 +}
70 +
71 +#ifndef SHA256_NEEDS_CLONE_HELPER
72 +static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *src)
73 +{
74 + memcpy(dst, src, sizeof(*dst));
75 +}
76 +#endif
77 +
78 +/*
79 + * Note that these constants are suitable for indexing the hash_algos array and
80 + * comparing against each other, but are otherwise arbitrary, so they should not
81 + * be exposed to the user or serialized to disk. To know whether a
82 + * git_hash_algo struct points to some usable hash function, test the format_id
83 + * field for being non-zero. Use the name field for user-visible situations and
84 + * the format_id field for fixed-length fields on disk.
85 + */
86 +/* An unknown hash function. */
87 +#define GIT_HASH_UNKNOWN 0
88 +/* SHA-1 */
89 +#define GIT_HASH_SHA1 1
90 +/* SHA-256 */
91 +#define GIT_HASH_SHA256 2
92 +/* Number of algorithms supported (including unknown). */
93 +#define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)
94 +
95 +/* "sha1", big-endian */
96 +#define GIT_SHA1_FORMAT_ID 0x73686131
97 +
98 +/* The length in bytes and in hex digits of an object name (SHA-1 value). */
99 +#define GIT_SHA1_RAWSZ 20
100 +#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
101 +/* The block size of SHA-1. */
102 +#define GIT_SHA1_BLKSZ 64
103 +
104 +/* "s256", big-endian */
105 +#define GIT_SHA256_FORMAT_ID 0x73323536
106 +
107 +/* The length in bytes and in hex digits of an object name (SHA-256 value). */
108 +#define GIT_SHA256_RAWSZ 32
109 +#define GIT_SHA256_HEXSZ (2 * GIT_SHA256_RAWSZ)
110 +/* The block size of SHA-256. */
111 +#define GIT_SHA256_BLKSZ 64
112 +
113 +/* The length in byte and in hex digits of the largest possible hash value. */
114 +#define GIT_MAX_RAWSZ GIT_SHA256_RAWSZ
115 +#define GIT_MAX_HEXSZ GIT_SHA256_HEXSZ
116 +/* The largest possible block size for any supported hash. */
117 +#define GIT_MAX_BLKSZ GIT_SHA256_BLKSZ
118 +
119 +struct object_id {
120 + unsigned char hash[GIT_MAX_RAWSZ];
121 + int algo; /* XXX requires 4-byte alignment */
122 +};
123 +
124 +#define GET_OID_QUIETLY 01
125 +#define GET_OID_COMMIT 02
126 +#define GET_OID_COMMITTISH 04
127 +#define GET_OID_TREE 010
128 +#define GET_OID_TREEISH 020
129 +#define GET_OID_BLOB 040
130 +#define GET_OID_FOLLOW_SYMLINKS 0100
131 +#define GET_OID_RECORD_PATH 0200
132 +#define GET_OID_ONLY_TO_DIE 04000
133 +#define GET_OID_REQUIRE_PATH 010000
134 +
135 +#define GET_OID_DISAMBIGUATORS \
136 + (GET_OID_COMMIT | GET_OID_COMMITTISH | \
137 + GET_OID_TREE | GET_OID_TREEISH | \
138 + GET_OID_BLOB)
139 +
140 +enum get_oid_result {
141 + FOUND = 0,
142 + MISSING_OBJECT = -1, /* The requested object is missing */
143 + SHORT_NAME_AMBIGUOUS = -2,
144 + /* The following only apply when symlinks are followed */
145 + DANGLING_SYMLINK = -4, /*
146 + * The initial symlink is there, but
147 + * (transitively) points to a missing
148 + * in-tree file
149 + */
150 + SYMLINK_LOOP = -5,
151 + NOT_DIR = -6, /*
152 + * Somewhere along the symlink chain, a path is
153 + * requested which contains a file as a
154 + * non-final element.
155 + */
156 +};
157 +
158 +/* A suitably aligned type for stack allocations of hash contexts. */
159 +union git_hash_ctx {
160 + git_SHA_CTX sha1;
161 + git_SHA256_CTX sha256;
162 +};
163 +typedef union git_hash_ctx git_hash_ctx;
164 +
165 +typedef void (*git_hash_init_fn)(git_hash_ctx *ctx);
166 +typedef void (*git_hash_clone_fn)(git_hash_ctx *dst, const git_hash_ctx *src);
167 +typedef void (*git_hash_update_fn)(git_hash_ctx *ctx, const void *in, size_t len);
168 +typedef void (*git_hash_final_fn)(unsigned char *hash, git_hash_ctx *ctx);
169 +typedef void (*git_hash_final_oid_fn)(struct object_id *oid, git_hash_ctx *ctx);
170 +
171 +struct git_hash_algo {
172 + /*
173 + * The name of the algorithm, as appears in the config file and in
174 + * messages.
175 + */
176 + const char *name;
177 +
178 + /* A four-byte version identifier, used in pack indices. */
179 + uint32_t format_id;
180 +
181 + /* The length of the hash in binary. */
182 + size_t rawsz;
183 +
184 + /* The length of the hash in hex characters. */
185 + size_t hexsz;
186 +
187 + /* The block size of the hash. */
188 + size_t blksz;
189 +
190 + /* The hash initialization function. */
191 + git_hash_init_fn init_fn;
192 +
193 + /* The hash context cloning function. */
194 + git_hash_clone_fn clone_fn;
195 +
196 + /* The hash update function. */
197 + git_hash_update_fn update_fn;
198 +
199 + /* The hash finalization function. */
200 + git_hash_final_fn final_fn;
201 +
202 + /* The hash finalization function for object IDs. */
203 + git_hash_final_oid_fn final_oid_fn;
204 +
205 + /* The OID of the empty tree. */
206 + const struct object_id *empty_tree;
207 +
208 + /* The OID of the empty blob. */
209 + const struct object_id *empty_blob;
210 +
211 + /* The all-zeros OID. */
212 + const struct object_id *null_oid;
213 +};
214 +extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];
215 +
216 +/*
217 + * Return a GIT_HASH_* constant based on the name. Returns GIT_HASH_UNKNOWN if
218 + * the name doesn't match a known algorithm.
219 + */
220 +int hash_algo_by_name(const char *name);
221 +/* Identical, except based on the format ID. */
222 +int hash_algo_by_id(uint32_t format_id);
223 +/* Identical, except based on the length. */
224 +int hash_algo_by_length(int len);
225 +/* Identical, except for a pointer to struct git_hash_algo. */
226 +static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
227 +{
228 + return p - hash_algos;
229 +}
230 +
231 +const struct object_id *null_oid(void);
232 +
233 +static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
234 +{
235 + /*
236 + * Teach the compiler that there are only two possibilities of hash size
237 + * here, so that it can optimize for this case as much as possible.
238 + */
239 + if (algop->rawsz == GIT_MAX_RAWSZ)
240 + return memcmp(sha1, sha2, GIT_MAX_RAWSZ);
241 + return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
242 +}
243 +
244 +static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
245 +{
246 + /*
247 + * We write this here instead of deferring to hashcmp so that the
248 + * compiler can properly inline it and avoid calling memcmp.
249 + */
250 + if (algop->rawsz == GIT_MAX_RAWSZ)
251 + return !memcmp(sha1, sha2, GIT_MAX_RAWSZ);
252 + return !memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
253 +}
254 +
255 +static inline void oidcpy(struct object_id *dst, const struct object_id *src)
256 +{
257 + memcpy(dst->hash, src->hash, GIT_MAX_RAWSZ);
258 + dst->algo = src->algo;
259 +}
260 +
261 +static inline struct object_id *oiddup(const struct object_id *src)
262 +{
263 + struct object_id *dst = xmalloc(sizeof(struct object_id));
264 + oidcpy(dst, src);
265 + return dst;
266 +}
267 +
268 +static inline void oid_set_algo(struct object_id *oid, const struct git_hash_algo *algop)
269 +{
270 + oid->algo = hash_algo_by_ptr(algop);
271 +}
272 +
273 +const char *empty_tree_oid_hex(void);
274 +const char *empty_blob_oid_hex(void);
275 +
276 +#endif
hash-lookup.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "hash.h"
3 #include "hash-lookup.h"
4
5 static uint32_t take2(const struct object_id *oid, size_t ofs)
hash.h
+1 -272
@@ -1,250 +1,11 @@
1 #ifndef HASH_H
2 #define HASH_H
3
4 +#include "hash-ll.h"
5 #include "repository.h"
6
6 -#if defined(SHA1_APPLE)
7 -#include <CommonCrypto/CommonDigest.h>
8 -#elif defined(SHA1_OPENSSL)
9 -#include <openssl/sha.h>
10 -#elif defined(SHA1_DC)
11 -#include "sha1dc_git.h"
12 -#else /* SHA1_BLK */
13 -#include "block-sha1/sha1.h"
14 -#endif
15 -
16 -#if defined(SHA256_NETTLE)
17 -#include "sha256/nettle.h"
18 -#elif defined(SHA256_GCRYPT)
19 -#define SHA256_NEEDS_CLONE_HELPER
20 -#include "sha256/gcrypt.h"
21 -#elif defined(SHA256_OPENSSL)
22 -#include <openssl/sha.h>
23 -#else
24 -#include "sha256/block/sha256.h"
25 -#endif
26 -
27 -#ifndef platform_SHA_CTX
28 -/*
29 - * platform's underlying implementation of SHA-1; could be OpenSSL,
30 - * blk_SHA, Apple CommonCrypto, etc... Note that the relevant
31 - * SHA-1 header may have already defined platform_SHA_CTX for our
32 - * own implementations like block-sha1, so we list
33 - * the default for OpenSSL compatible SHA-1 implementations here.
34 - */
35 -#define platform_SHA_CTX SHA_CTX
36 -#define platform_SHA1_Init SHA1_Init
37 -#define platform_SHA1_Update SHA1_Update
38 -#define platform_SHA1_Final SHA1_Final
39 -#endif
40 -
41 -#define git_SHA_CTX platform_SHA_CTX
42 -#define git_SHA1_Init platform_SHA1_Init
43 -#define git_SHA1_Update platform_SHA1_Update
44 -#define git_SHA1_Final platform_SHA1_Final
45 -
46 -#ifndef platform_SHA256_CTX
47 -#define platform_SHA256_CTX SHA256_CTX
48 -#define platform_SHA256_Init SHA256_Init
49 -#define platform_SHA256_Update SHA256_Update
50 -#define platform_SHA256_Final SHA256_Final
51 -#endif
52 -
53 -#define git_SHA256_CTX platform_SHA256_CTX
54 -#define git_SHA256_Init platform_SHA256_Init
55 -#define git_SHA256_Update platform_SHA256_Update
56 -#define git_SHA256_Final platform_SHA256_Final
57 -
58 -#ifdef platform_SHA256_Clone
59 -#define git_SHA256_Clone platform_SHA256_Clone
60 -#endif
61 -
62 -#ifdef SHA1_MAX_BLOCK_SIZE
63 -#include "compat/sha1-chunked.h"
64 -#undef git_SHA1_Update
65 -#define git_SHA1_Update git_SHA1_Update_Chunked
66 -#endif
67 -
68 -static inline void git_SHA1_Clone(git_SHA_CTX *dst, const git_SHA_CTX *src)
69 -{
70 - memcpy(dst, src, sizeof(*dst));
71 -}
72 -
73 -#ifndef SHA256_NEEDS_CLONE_HELPER
74 -static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *src)
75 -{
76 - memcpy(dst, src, sizeof(*dst));
77 -}
78 -#endif
79 -
80 -/*
81 - * Note that these constants are suitable for indexing the hash_algos array and
82 - * comparing against each other, but are otherwise arbitrary, so they should not
83 - * be exposed to the user or serialized to disk. To know whether a
84 - * git_hash_algo struct points to some usable hash function, test the format_id
85 - * field for being non-zero. Use the name field for user-visible situations and
86 - * the format_id field for fixed-length fields on disk.
87 - */
88 -/* An unknown hash function. */
89 -#define GIT_HASH_UNKNOWN 0
90 -/* SHA-1 */
91 -#define GIT_HASH_SHA1 1
92 -/* SHA-256 */
93 -#define GIT_HASH_SHA256 2
94 -/* Number of algorithms supported (including unknown). */
95 -#define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)
96 -
97 -/* "sha1", big-endian */
98 -#define GIT_SHA1_FORMAT_ID 0x73686131
99 -
100 -/* The length in bytes and in hex digits of an object name (SHA-1 value). */
101 -#define GIT_SHA1_RAWSZ 20
102 -#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
103 -/* The block size of SHA-1. */
104 -#define GIT_SHA1_BLKSZ 64
105 -
106 -/* "s256", big-endian */
107 -#define GIT_SHA256_FORMAT_ID 0x73323536
108 -
109 -/* The length in bytes and in hex digits of an object name (SHA-256 value). */
110 -#define GIT_SHA256_RAWSZ 32
111 -#define GIT_SHA256_HEXSZ (2 * GIT_SHA256_RAWSZ)
112 -/* The block size of SHA-256. */
113 -#define GIT_SHA256_BLKSZ 64
114 -
115 -/* The length in byte and in hex digits of the largest possible hash value. */
116 -#define GIT_MAX_RAWSZ GIT_SHA256_RAWSZ
117 -#define GIT_MAX_HEXSZ GIT_SHA256_HEXSZ
118 -/* The largest possible block size for any supported hash. */
119 -#define GIT_MAX_BLKSZ GIT_SHA256_BLKSZ
120 -
121 -struct object_id {
122 - unsigned char hash[GIT_MAX_RAWSZ];
123 - int algo; /* XXX requires 4-byte alignment */
124 -};
125 -
126 -#define GET_OID_QUIETLY 01
127 -#define GET_OID_COMMIT 02
128 -#define GET_OID_COMMITTISH 04
129 -#define GET_OID_TREE 010
130 -#define GET_OID_TREEISH 020
131 -#define GET_OID_BLOB 040
132 -#define GET_OID_FOLLOW_SYMLINKS 0100
133 -#define GET_OID_RECORD_PATH 0200
134 -#define GET_OID_ONLY_TO_DIE 04000
135 -#define GET_OID_REQUIRE_PATH 010000
136 -
137 -#define GET_OID_DISAMBIGUATORS \
138 - (GET_OID_COMMIT | GET_OID_COMMITTISH | \
139 - GET_OID_TREE | GET_OID_TREEISH | \
140 - GET_OID_BLOB)
141 -
142 -enum get_oid_result {
143 - FOUND = 0,
144 - MISSING_OBJECT = -1, /* The requested object is missing */
145 - SHORT_NAME_AMBIGUOUS = -2,
146 - /* The following only apply when symlinks are followed */
147 - DANGLING_SYMLINK = -4, /*
148 - * The initial symlink is there, but
149 - * (transitively) points to a missing
150 - * in-tree file
151 - */
152 - SYMLINK_LOOP = -5,
153 - NOT_DIR = -6, /*
154 - * Somewhere along the symlink chain, a path is
155 - * requested which contains a file as a
156 - * non-final element.
157 - */
158 -};
159 -
160 -/* A suitably aligned type for stack allocations of hash contexts. */
161 -union git_hash_ctx {
162 - git_SHA_CTX sha1;
163 - git_SHA256_CTX sha256;
164 -};
165 -typedef union git_hash_ctx git_hash_ctx;
166 -
167 -typedef void (*git_hash_init_fn)(git_hash_ctx *ctx);
168 -typedef void (*git_hash_clone_fn)(git_hash_ctx *dst, const git_hash_ctx *src);
169 -typedef void (*git_hash_update_fn)(git_hash_ctx *ctx, const void *in, size_t len);
170 -typedef void (*git_hash_final_fn)(unsigned char *hash, git_hash_ctx *ctx);
171 -typedef void (*git_hash_final_oid_fn)(struct object_id *oid, git_hash_ctx *ctx);
172 -
173 -struct git_hash_algo {
174 - /*
175 - * The name of the algorithm, as appears in the config file and in
176 - * messages.
177 - */
178 - const char *name;
179 -
180 - /* A four-byte version identifier, used in pack indices. */
181 - uint32_t format_id;
182 -
183 - /* The length of the hash in binary. */
184 - size_t rawsz;
185 -
186 - /* The length of the hash in hex characters. */
187 - size_t hexsz;
188 -
189 - /* The block size of the hash. */
190 - size_t blksz;
191 -
192 - /* The hash initialization function. */
193 - git_hash_init_fn init_fn;
194 -
195 - /* The hash context cloning function. */
196 - git_hash_clone_fn clone_fn;
197 -
198 - /* The hash update function. */
199 - git_hash_update_fn update_fn;
200 -
201 - /* The hash finalization function. */
202 - git_hash_final_fn final_fn;
203 -
204 - /* The hash finalization function for object IDs. */
205 - git_hash_final_oid_fn final_oid_fn;
206 -
207 - /* The OID of the empty tree. */
208 - const struct object_id *empty_tree;
209 -
210 - /* The OID of the empty blob. */
211 - const struct object_id *empty_blob;
212 -
213 - /* The all-zeros OID. */
214 - const struct object_id *null_oid;
215 -};
216 -extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];
217 -
218 -/*
219 - * Return a GIT_HASH_* constant based on the name. Returns GIT_HASH_UNKNOWN if
220 - * the name doesn't match a known algorithm.
221 - */
222 -int hash_algo_by_name(const char *name);
223 -/* Identical, except based on the format ID. */
224 -int hash_algo_by_id(uint32_t format_id);
225 -/* Identical, except based on the length. */
226 -int hash_algo_by_length(int len);
227 -/* Identical, except for a pointer to struct git_hash_algo. */
228 -static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
229 -{
230 - return p - hash_algos;
231 -}
232 -
7 #define the_hash_algo the_repository->hash_algo
8
235 -const struct object_id *null_oid(void);
236 -
237 -static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
238 -{
239 - /*
240 - * Teach the compiler that there are only two possibilities of hash size
241 - * here, so that it can optimize for this case as much as possible.
242 - */
243 - if (algop->rawsz == GIT_MAX_RAWSZ)
244 - return memcmp(sha1, sha2, GIT_MAX_RAWSZ);
245 - return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
246 -}
247 -
9 static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
10 {
11 return hashcmp_algop(sha1, sha2, the_hash_algo);
@@ -260,17 +21,6 @@ static inline int oidcmp(const struct object_id *oid1, const struct object_id *o
21 return hashcmp_algop(oid1->hash, oid2->hash, algop);
22 }
23
263 -static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
264 -{
265 - /*
266 - * We write this here instead of deferring to hashcmp so that the
267 - * compiler can properly inline it and avoid calling memcmp.
268 - */
269 - if (algop->rawsz == GIT_MAX_RAWSZ)
270 - return !memcmp(sha1, sha2, GIT_MAX_RAWSZ);
271 - return !memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
272 -}
273 -
24 static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
25 {
26 return hasheq_algop(sha1, sha2, the_hash_algo);
@@ -296,12 +46,6 @@ static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
46 memcpy(sha_dst, sha_src, the_hash_algo->rawsz);
47 }
48
299 -static inline void oidcpy(struct object_id *dst, const struct object_id *src)
300 -{
301 - memcpy(dst->hash, src->hash, GIT_MAX_RAWSZ);
302 - dst->algo = src->algo;
303 -}
304 -
49 /* Like oidcpy() but zero-pads the unused bytes in dst's hash array. */
50 static inline void oidcpy_with_padding(struct object_id *dst,
51 const struct object_id *src)
@@ -318,13 +62,6 @@ static inline void oidcpy_with_padding(struct object_id *dst,
62 dst->algo = src->algo;
63 }
64
321 -static inline struct object_id *oiddup(const struct object_id *src)
322 -{
323 - struct object_id *dst = xmalloc(sizeof(struct object_id));
324 - oidcpy(dst, src);
325 - return dst;
326 -}
327 -
65 static inline void hashclr(unsigned char *hash)
66 {
67 memset(hash, 0, the_hash_algo->rawsz);
@@ -362,12 +99,4 @@ static inline int is_empty_tree_oid(const struct object_id *oid)
99 return oideq(oid, the_hash_algo->empty_tree);
100 }
101
365 -static inline void oid_set_algo(struct object_id *oid, const struct git_hash_algo *algop)
366 -{
367 - oid->algo = hash_algo_by_ptr(algop);
368 -}
369 -
370 -const char *empty_tree_oid_hex(void);
371 -const char *empty_blob_oid_hex(void);
372 -
102 #endif
hashmap.h
+1 -1
@@ -1,7 +1,7 @@
1 #ifndef HASHMAP_H
2 #define HASHMAP_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5
6 /*
7 * Generic implementation of hash-based key-value mappings.
hex.c
+1
@@ -1,4 +1,5 @@
1 #include "git-compat-util.h"
2 +#include "hash.h"
3 #include "hex.h"
4
5 const signed char hexval_table[256] = {
hex.h
+1 -1
@@ -1,7 +1,7 @@
1 #ifndef HEX_H
2 #define HEX_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5
6 extern const signed char hexval_table[256];
7 static inline unsigned int hexval(unsigned char c)
hook.c
+1
@@ -2,6 +2,7 @@
2 #include "advice.h"
3 #include "gettext.h"
4 #include "hook.h"
5 +#include "path.h"
6 #include "run-command.h"
7 #include "config.h"
8 #include "strbuf.h"
khash.h
+1
@@ -27,6 +27,7 @@
27 #define __AC_KHASH_H
28
29 #include "hashmap.h"
30 +#include "hash.h"
31
32 #define AC_VERSION_KHASH_H "0.2.8"
33
ls-refs.c
+1
@@ -1,6 +1,7 @@
1 #include "git-compat-util.h"
2 #include "environment.h"
3 #include "gettext.h"
4 +#include "hash.h"
5 #include "hex.h"
6 #include "repository.h"
7 #include "refs.h"
merge-ort-wrappers.c
+1
@@ -1,5 +1,6 @@
1 #include "cache.h"
2 #include "gettext.h"
3 +#include "hash.h"
4 #include "merge-ort.h"
5 #include "merge-ort-wrappers.h"
6
merge-ort.h
+1 -1
@@ -2,7 +2,7 @@
2 #define MERGE_ORT_H
3
4 #include "merge-recursive.h"
5 -#include "hash.h"
5 +#include "hash-ll.h"
6
7 struct commit;
8 struct tree;
negotiator/default.c
+1
@@ -4,6 +4,7 @@
4 #include "../fetch-negotiator.h"
5 #include "../prio-queue.h"
6 #include "../refs.h"
7 +#include "../repository.h"
8 #include "../tag.h"
9
10 /* Remember to update object flag allocation in object.h */
negotiator/skipping.c
+1
@@ -5,6 +5,7 @@
5 #include "../hex.h"
6 #include "../prio-queue.h"
7 #include "../refs.h"
8 +#include "../repository.h"
9 #include "../tag.h"
10
11 /* Remember to update object flag allocation in object.h */
object-file.h
+2
@@ -4,6 +4,8 @@
4 #include "git-zlib.h"
5 #include "object.h"
6
7 +struct index_state;
8 +
9 /*
10 * Set this to 0 to prevent oid_object_info_extended() from fetching missing
11 * blobs. This has a difference only if extensions.partialClone is set.
object.h
+2 -1
@@ -1,9 +1,10 @@
1 #ifndef OBJECT_H
2 #define OBJECT_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5
6 struct buffer_slab;
7 +struct repository;
8
9 struct parsed_object_pool {
10 struct object **obj_hash;
oidmap.c
+1
@@ -1,4 +1,5 @@
1 #include "git-compat-util.h"
2 +#include "hash.h"
3 #include "oidmap.h"
4
5 static int oidmap_neq(const void *hashmap_cmp_fn_data UNUSED,
oidtree.h
+1 -1
@@ -2,7 +2,7 @@
2 #define OIDTREE_H
3
4 #include "cbtree.h"
5 -#include "hash.h"
5 +#include "hash-ll.h"
6 #include "mem-pool.h"
7
8 struct oidtree {
parallel-checkout.c
+1
@@ -3,6 +3,7 @@
3 #include "config.h"
4 #include "entry.h"
5 #include "gettext.h"
6 +#include "hash.h"
7 #include "hex.h"
8 #include "parallel-checkout.h"
9 #include "pkt-line.h"
pathspec.c
+1
@@ -6,6 +6,7 @@
6 #include "gettext.h"
7 #include "pathspec.h"
8 #include "attr.h"
9 +#include "repository.h"
10 #include "setup.h"
11 #include "strvec.h"
12 #include "symlinks.h"
progress.c
+1
@@ -12,6 +12,7 @@
12 #include "git-compat-util.h"
13 #include "pager.h"
14 #include "progress.h"
15 +#include "repository.h"
16 #include "strbuf.h"
17 #include "trace.h"
18 #include "trace2.h"
protocol-caps.c
+1 -1
@@ -4,7 +4,7 @@
4 #include "hex.h"
5 #include "pkt-line.h"
6 #include "strvec.h"
7 -#include "hash.h"
7 +#include "hash-ll.h"
8 #include "hex.h"
9 #include "object.h"
10 #include "object-store.h"
rebase-interactive.c
+1
@@ -5,6 +5,7 @@
5 #include "gettext.h"
6 #include "sequencer.h"
7 #include "rebase-interactive.h"
8 +#include "repository.h"
9 #include "strbuf.h"
10 #include "commit-slab.h"
11 #include "config.h"
refs/files-backend.c
+1
@@ -3,6 +3,7 @@
3 #include "../copy.h"
4 #include "../environment.h"
5 #include "../gettext.h"
6 +#include "../hash.h"
7 #include "../hex.h"
8 #include "../refs.h"
9 #include "refs-internal.h"
refs/packed-backend.c
+1
@@ -2,6 +2,7 @@
2 #include "../alloc.h"
3 #include "../config.h"
4 #include "../gettext.h"
5 +#include "../hash.h"
6 #include "../hex.h"
7 #include "../refs.h"
8 #include "refs-internal.h"
refs/ref-cache.c
+2
@@ -1,6 +1,8 @@
1 #include "../git-compat-util.h"
2 #include "../alloc.h"
3 +#include "../hash.h"
4 #include "../refs.h"
5 +#include "../repository.h"
6 #include "refs-internal.h"
7 #include "ref-cache.h"
8 #include "../iterator.h"
refs/ref-cache.h
+2 -1
@@ -1,10 +1,11 @@
1 #ifndef REFS_REF_CACHE_H
2 #define REFS_REF_CACHE_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5
6 struct ref_dir;
7 struct ref_store;
8 +struct repository;
9
10 /*
11 * If this ref_cache is filled lazily, this function is used to load
refspec.c
+1
@@ -1,6 +1,7 @@
1 #include "git-compat-util.h"
2 #include "alloc.h"
3 #include "gettext.h"
4 +#include "hash.h"
5 #include "hex.h"
6 #include "strvec.h"
7 #include "refs.h"
reftable/dump.c
+1 -1
@@ -7,7 +7,7 @@ https://developers.google.com/open-source/licenses/bsd
7 */
8
9 #include "git-compat-util.h"
10 -#include "hash.h"
10 +#include "hash-ll.h"
11
12 #include "reftable-blocksource.h"
13 #include "reftable-error.h"
reftable/system.h
+1 -1
@@ -13,7 +13,7 @@ https://developers.google.com/open-source/licenses/bsd
13
14 #include "git-compat-util.h"
15 #include "strbuf.h"
16 -#include "hash.h" /* hash ID, sizes.*/
16 +#include "hash-ll.h" /* hash ID, sizes.*/
17 #include "dir.h" /* remove_dir_recursively, for tests.*/
18
19 int hash_size(uint32_t id);
reset.h
+1 -1
@@ -1,7 +1,7 @@
1 #ifndef RESET_H
2 #define RESET_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5 #include "repository.h"
6
7 #define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
resolve-undo.c
+1
@@ -1,5 +1,6 @@
1 #include "cache.h"
2 #include "dir.h"
3 +#include "hash.h"
4 #include "resolve-undo.h"
5 #include "string-list.h"
6
resolve-undo.h
+1 -1
@@ -6,7 +6,7 @@ struct index_state;
6 struct pathspec;
7 struct string_list;
8
9 -#include "hash.h"
9 +#include "hash-ll.h"
10
11 struct resolve_undo_info {
12 unsigned int mode[3];
split-index.c
+1
@@ -1,6 +1,7 @@
1 #include "cache.h"
2 #include "alloc.h"
3 #include "gettext.h"
4 +#include "hash.h"
5 #include "mem-pool.h"
6 #include "split-index.h"
7 #include "strbuf.h"
split-index.h
+1 -1
@@ -1,7 +1,7 @@
1 #ifndef SPLIT_INDEX_H
2 #define SPLIT_INDEX_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5
6 struct index_state;
7 struct strbuf;
strbuf.c
+1
@@ -6,6 +6,7 @@
6 #include "hex.h"
7 #include "object-name.h"
8 #include "refs.h"
9 +#include "repository.h"
10 #include "string-list.h"
11 #include "utf8.h"
12 #include "date.h"
t/helper/test-bloom.c
+1
@@ -2,6 +2,7 @@
2 #include "bloom.h"
3 #include "hex.h"
4 #include "commit.h"
5 +#include "repository.h"
6 #include "setup.h"
7
8 static struct bloom_filter_settings settings = DEFAULT_BLOOM_FILTER_SETTINGS;
t/helper/test-cache-tree.c
+1
@@ -6,6 +6,7 @@
6 #include "tree.h"
7 #include "cache-tree.h"
8 #include "parse-options.h"
9 +#include "repository.h"
10 #include "setup.h"
11
12 static char const * const test_cache_tree_usage[] = {
t/helper/test-dump-cache-tree.c
+2
@@ -1,9 +1,11 @@
1 #define USE_THE_INDEX_VARIABLE
2 #include "test-tool.h"
3 #include "cache.h"
4 +#include "hash.h"
5 #include "hex.h"
6 #include "tree.h"
7 #include "cache-tree.h"
8 +#include "repository.h"
9 #include "setup.h"
10
11 static void dump_one(struct cache_tree *it, const char *pfx, const char *x)
t/helper/test-dump-fsmonitor.c
+1
@@ -1,5 +1,6 @@
1 #include "test-tool.h"
2 #include "cache.h"
3 +#include "repository.h"
4 #include "setup.h"
5
6 int cmd__dump_fsmonitor(int ac, const char **av)
t/helper/test-dump-untracked-cache.c
+1
@@ -3,6 +3,7 @@
3 #include "cache.h"
4 #include "dir.h"
5 #include "hex.h"
6 +#include "repository.h"
7 #include "setup.h"
8
9 static int compare_untracked(const void *a_, const void *b_)
t/helper/test-example-decorate.c
+1
@@ -2,6 +2,7 @@
2 #include "git-compat-util.h"
3 #include "object.h"
4 #include "decorate.h"
5 +#include "repository.h"
6
7 int cmd__example_decorate(int argc, const char **argv)
8 {
t/helper/test-fsmonitor-client.c
+1
@@ -7,6 +7,7 @@
7 #include "cache.h"
8 #include "parse-options.h"
9 #include "fsmonitor-ipc.h"
10 +#include "repository.h"
11 #include "setup.h"
12 #include "thread-utils.h"
13 #include "trace2.h"
t/helper/test-lazy-init-name-hash.c
+1
@@ -3,6 +3,7 @@
3 #include "cache.h"
4 #include "environment.h"
5 #include "parse-options.h"
6 +#include "repository.h"
7 #include "setup.h"
8 #include "trace.h"
9
t/helper/test-match-trees.c
+1
@@ -3,6 +3,7 @@
3 #include "hex.h"
4 #include "match-trees.h"
5 #include "object-name.h"
6 +#include "repository.h"
7 #include "setup.h"
8 #include "tree.h"
9
t/helper/test-oidmap.c
+1
@@ -2,6 +2,7 @@
2 #include "hex.h"
3 #include "object-name.h"
4 #include "oidmap.h"
5 +#include "repository.h"
6 #include "setup.h"
7 #include "strbuf.h"
8
t/helper/test-path-utils.c
+1
@@ -2,6 +2,7 @@
2 #include "cache.h"
3 #include "abspath.h"
4 #include "environment.h"
5 +#include "path.h"
6 #include "setup.h"
7 #include "string-list.h"
8 #include "trace.h"
t/helper/test-read-cache.c
+1
@@ -2,6 +2,7 @@
2 #include "test-tool.h"
3 #include "cache.h"
4 #include "config.h"
5 +#include "repository.h"
6 #include "setup.h"
7 #include "wrapper.h"
8
t/helper/test-scrap-cache-tree.c
+1
@@ -2,6 +2,7 @@
2 #include "test-tool.h"
3 #include "cache.h"
4 #include "lockfile.h"
5 +#include "repository.h"
6 #include "setup.h"
7 #include "tree.h"
8 #include "cache-tree.h"
t/helper/test-submodule-config.c
+2
@@ -1,6 +1,8 @@
1 #include "test-tool.h"
2 #include "config.h"
3 +#include "hash.h"
4 #include "object-name.h"
5 +#include "repository.h"
6 #include "setup.h"
7 #include "submodule-config.h"
8 #include "submodule.h"
t/helper/test-submodule-nested-repo-config.c
+1
@@ -1,4 +1,5 @@
1 #include "test-tool.h"
2 +#include "repository.h"
3 #include "setup.h"
4 #include "submodule-config.h"
5
t/helper/test-submodule.c
+1
@@ -2,6 +2,7 @@
2 #include "test-tool-utils.h"
3 #include "parse-options.h"
4 #include "remote.h"
5 +#include "repository.h"
6 #include "setup.h"
7 #include "submodule-config.h"
8 #include "submodule.h"
t/helper/test-trace2.c
+1
@@ -3,6 +3,7 @@
3 #include "run-command.h"
4 #include "exec-cmd.h"
5 #include "config.h"
6 +#include "repository.h"
7 #include "trace2.h"
8
9 typedef int(fn_unit_test)(int argc, const char **argv);
t/helper/test-write-cache.c
+1
@@ -2,6 +2,7 @@
2 #include "test-tool.h"
3 #include "cache.h"
4 #include "lockfile.h"
5 +#include "repository.h"
6 #include "setup.h"
7
8 int cmd__write_cache(int argc, const char **argv)
trace2.c
+1
@@ -2,6 +2,7 @@
2 #include "config.h"
3 #include "json-writer.h"
4 #include "quote.h"
5 +#include "repository.h"
6 #include "run-command.h"
7 #include "sigchain.h"
8 #include "thread-utils.h"
trace2/tr2_tgt_event.c
+1
@@ -1,6 +1,7 @@
1 #include "git-compat-util.h"
2 #include "config.h"
3 #include "json-writer.h"
4 +#include "repository.h"
5 #include "run-command.h"
6 #include "version.h"
7 #include "trace2/tr2_dst.h"
trace2/tr2_tgt_normal.c
+1
@@ -1,5 +1,6 @@
1 #include "git-compat-util.h"
2 #include "config.h"
3 +#include "repository.h"
4 #include "run-command.h"
5 #include "quote.h"
6 #include "version.h"
trace2/tr2_tgt_perf.c
+1
@@ -1,5 +1,6 @@
1 #include "git-compat-util.h"
2 #include "config.h"
3 +#include "repository.h"
4 #include "run-command.h"
5 #include "quote.h"
6 #include "version.h"
tree-walk.h
+2 -1
@@ -1,9 +1,10 @@
1 #ifndef TREE_WALK_H
2 #define TREE_WALK_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5
6 struct index_state;
7 +struct repository;
8
9 #define MAX_TRAVERSE_TREES 8
10
tree.h
+1
@@ -3,6 +3,7 @@
3
4 #include "object.h"
5
6 +struct pathspec;
7 struct repository;
8 struct strbuf;
9
wrapper.c
+1
@@ -5,6 +5,7 @@
5 #include "abspath.h"
6 #include "config.h"
7 #include "gettext.h"
8 +#include "repository.h"
9 #include "strbuf.h"
10 #include "trace2.h"
11 #include "wrapper.h"
xdiff-interface.h
+1 -1
@@ -1,7 +1,7 @@
1 #ifndef XDIFF_INTERFACE_H
2 #define XDIFF_INTERFACE_H
3
4 -#include "hash.h"
4 +#include "hash-ll.h"
5 #include "xdiff/xdiff.h"
6
7 /*