hash.h: move some oid-related declarations from cache.h
These defines and enum are all oid-related and as such seem to make more sense being included in hash.h. Further, moving them there allows us to remove some includes of cache.h in other files. The change to line-log.h might look unrelated, but line-log.h includes diffcore.h, which previously included cache.h, which included the kitchen sink. Since this patch makes diffcore.h no longer include cache.h, the compiler complains about the 'struct string_list *' function parameter. Add a forward declaration for struct string_list to address this. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Feb 24, 2023 at 00:09 UTC
41227cb138c91fbd369ac6ee4877f253b39260cc
7 files changed
+42
-37
cache.h
-34
@@ -1363,40 +1363,6 @@ struct object_context {
1363
char *path;
1364
};
1365
1366
-#define GET_OID_QUIETLY 01
1367
-#define GET_OID_COMMIT 02
1368
-#define GET_OID_COMMITTISH 04
1369
-#define GET_OID_TREE 010
1370
-#define GET_OID_TREEISH 020
1371
-#define GET_OID_BLOB 040
1372
-#define GET_OID_FOLLOW_SYMLINKS 0100
1373
-#define GET_OID_RECORD_PATH 0200
1374
-#define GET_OID_ONLY_TO_DIE 04000
1375
-#define GET_OID_REQUIRE_PATH 010000
1376
-
1377
-#define GET_OID_DISAMBIGUATORS \
1378
- (GET_OID_COMMIT | GET_OID_COMMITTISH | \
1379
- GET_OID_TREE | GET_OID_TREEISH | \
1380
- GET_OID_BLOB)
1381
-
1382
-enum get_oid_result {
1383
- FOUND = 0,
1384
- MISSING_OBJECT = -1, /* The requested object is missing */
1385
- SHORT_NAME_AMBIGUOUS = -2,
1386
- /* The following only apply when symlinks are followed */
1387
- DANGLING_SYMLINK = -4, /*
1388
- * The initial symlink is there, but
1389
- * (transitively) points to a missing
1390
- * in-tree file
1391
- */
1392
- SYMLINK_LOOP = -5,
1393
- NOT_DIR = -6, /*
1394
- * Somewhere along the symlink chain, a path is
1395
- * requested which contains a file as a
1396
- * non-final element.
1397
- */
1398
-};
1399
-
1366
int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
1367
__attribute__((format (printf, 2, 3)))
1368
int get_oidf(struct object_id *oid, const char *fmt, ...);
diffcore.h
+3
-1
@@ -4,9 +4,11 @@
4
#ifndef DIFFCORE_H
5
#define DIFFCORE_H
6
7
-#include "cache.h"
7
+#include "hash.h"
8
9
struct diff_options;
10
+struct mem_pool;
11
+struct oid_array;
12
struct repository;
13
struct strintmap;
14
struct strmap;
hash.h
+34
@@ -123,6 +123,40 @@ struct object_id {
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;
line-log.h
+1
@@ -5,6 +5,7 @@
5
6
struct rev_info;
7
struct commit;
8
+struct string_list;
9
10
/* A range [start,end]. Lines are numbered starting at 0, and the
11
* ranges include start but exclude end. */
submodule-config.h
-1
@@ -1,7 +1,6 @@
1
#ifndef SUBMODULE_CONFIG_CACHE_H
2
#define SUBMODULE_CONFIG_CACHE_H
3
4
-#include "cache.h"
4
#include "config.h"
5
#include "hashmap.h"
6
#include "submodule.h"
t/helper/test-submodule-nested-repo-config.c
+1
@@ -1,4 +1,5 @@
1
#include "test-tool.h"
2
+#include "cache.h"
3
#include "submodule-config.h"
4
5
static void die_usage(const char **argv, const char *msg)
tree-walk.h
+3
-1
@@ -1,7 +1,9 @@
1
#ifndef TREE_WALK_H
2
#define TREE_WALK_H
3
4
-#include "cache.h"
4
+#include "hash.h"
5
+
6
+struct index_state;
7
8
#define MAX_TRAVERSE_TREES 8
9