object.h: stop depending on cache.h; make cache.h depend on object.h
Things should be able to depend on object.h without pulling in all of cache.h. Move an enum to allow this. Note that a couple files previously depended on things brought in through cache.h indirectly (revision.h -> commit.h -> object.h -> cache.h). As such, this change requires making existing dependencies more explicit in half a dozen files. The inclusion of strbuf.h in some headers if of particular note: these headers directly embedded a strbuf in some new structs, meaning they should have been including strbuf.h all along but were indirectly getting the necessary definitions. 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
a64215b6cd5e67939187475c5b248dc5d13e3d60
17 files changed
+36
-32
alloc.c
+1
-1
@@ -8,7 +8,7 @@
8
* up with maximal alignment because it doesn't know what the object alignment
9
* for the new allocation is.
10
*/
11
-#include "cache.h"
11
+#include "git-compat-util.h"
12
#include "object.h"
13
#include "blob.h"
14
#include "tree.h"
blame.h
-1
@@ -1,7 +1,6 @@
1
#ifndef BLAME_H
2
#define BLAME_H
3
4
-#include "cache.h"
4
#include "commit.h"
5
#include "xdiff-interface.h"
6
#include "revision.h"
blob.c
+1
-1
@@ -1,4 +1,4 @@
1
-#include "cache.h"
1
+#include "git-compat-util.h"
2
#include "blob.h"
3
#include "repository.h"
4
#include "alloc.h"
cache-tree.h
-1
@@ -1,7 +1,6 @@
1
#ifndef CACHE_TREE_H
2
#define CACHE_TREE_H
3
4
-#include "cache.h"
4
#include "tree.h"
5
#include "tree-walk.h"
6
cache.h
+1
-20
@@ -14,6 +14,7 @@
14
#include "pack-revindex.h"
15
#include "hash.h"
16
#include "path.h"
17
+#include "object.h"
18
#include "oid-array.h"
19
#include "repository.h"
20
#include "mem-pool.h"
@@ -453,26 +454,6 @@ void prefetch_cache_entries(const struct index_state *istate,
454
extern struct index_state the_index;
455
#endif
456
456
-#define TYPE_BITS 3
457
-
458
-/*
459
- * Values in this enum (except those outside the 3 bit range) are part
460
- * of pack file format. See gitformat-pack(5) for more information.
461
- */
462
-enum object_type {
463
- OBJ_BAD = -1,
464
- OBJ_NONE = 0,
465
- OBJ_COMMIT = 1,
466
- OBJ_TREE = 2,
467
- OBJ_BLOB = 3,
468
- OBJ_TAG = 4,
469
- /* 5 for future expansion */
470
- OBJ_OFS_DELTA = 6,
471
- OBJ_REF_DELTA = 7,
472
- OBJ_ANY,
473
- OBJ_MAX
474
-};
475
-
457
static inline enum object_type object_type(unsigned int mode)
458
{
459
return S_ISDIR(mode) ? OBJ_TREE :
diff-merges.c
+1
@@ -1,6 +1,7 @@
1
#include "git-compat-util.h"
2
#include "diff-merges.h"
3
4
+#include "gettext.h"
5
#include "revision.h"
6
7
typedef void (*diff_merges_setup_func_t)(struct rev_info *);
diff.h
+1
-1
@@ -8,6 +8,7 @@
8
#include "pathspec.h"
9
#include "object.h"
10
#include "oidset.h"
11
+#include "strbuf.h"
12
13
/**
14
* The diff API is for programs that compare two sets of files (e.g. two trees,
@@ -71,7 +72,6 @@ struct oid_array;
72
struct option;
73
struct repository;
74
struct rev_info;
74
-struct strbuf;
75
struct userdiff_driver;
76
77
typedef int (*pathchange_fn_t)(struct diff_options *options,
diffcore-delta.c
+1
-1
@@ -1,4 +1,4 @@
1
-#include "cache.h"
1
+#include "git-compat-util.h"
2
#include "diff.h"
3
#include "diffcore.h"
4
fsck.h
+1
@@ -1,6 +1,7 @@
1
#ifndef GIT_FSCK_H
2
#define GIT_FSCK_H
3
4
+#include "object.h"
5
#include "oidset.h"
6
7
enum fsck_msg_type {
help.c
+1
@@ -5,6 +5,7 @@
5
#include "exec-cmd.h"
6
#include "run-command.h"
7
#include "levenshtein.h"
8
+#include "gettext.h"
9
#include "help.h"
10
#include "command-list.h"
11
#include "string-list.h"
list-objects-filter-options.h
+2
-1
@@ -1,9 +1,10 @@
1
#ifndef LIST_OBJECTS_FILTER_OPTIONS_H
2
#define LIST_OBJECTS_FILTER_OPTIONS_H
3
4
-#include "cache.h"
4
+#include "object.h"
5
#include "parse-options.h"
6
#include "string-list.h"
7
+#include "strbuf.h"
8
9
/*
10
* The list of defined filters for list-objects.
negotiator/noop.c
+1
-1
@@ -1,4 +1,4 @@
1
-#include "cache.h"
1
+#include "git-compat-util.h"
2
#include "noop.h"
3
#include "../commit.h"
4
#include "../fetch-negotiator.h"
object.h
+21
-1
@@ -1,7 +1,7 @@
1
#ifndef OBJECT_H
2
#define OBJECT_H
3
4
-#include "cache.h"
4
+#include "hash.h"
5
6
struct buffer_slab;
7
@@ -81,6 +81,26 @@ struct object_array {
81
*/
82
#define FLAG_BITS 28
83
84
+#define TYPE_BITS 3
85
+
86
+/*
87
+ * Values in this enum (except those outside the 3 bit range) are part
88
+ * of pack file format. See gitformat-pack(5) for more information.
89
+ */
90
+enum object_type {
91
+ OBJ_BAD = -1,
92
+ OBJ_NONE = 0,
93
+ OBJ_COMMIT = 1,
94
+ OBJ_TREE = 2,
95
+ OBJ_BLOB = 3,
96
+ OBJ_TAG = 4,
97
+ /* 5 for future expansion */
98
+ OBJ_OFS_DELTA = 6,
99
+ OBJ_REF_DELTA = 7,
100
+ OBJ_ANY,
101
+ OBJ_MAX
102
+};
103
+
104
/*
105
* The object type is stored in 3 bits.
106
*/
shallow.h
+2
@@ -6,6 +6,8 @@
6
#include "repository.h"
7
#include "strbuf.h"
8
9
+struct oid_array;
10
+
11
void set_alternate_shallow_file(struct repository *r, const char *path, int override);
12
int register_shallow(struct repository *r, const struct object_id *oid);
13
int unregister_shallow(const struct object_id *oid);
t/helper/test-bloom.c
+1
-1
@@ -1,4 +1,4 @@
1
-#include "git-compat-util.h"
1
+#include "cache.h"
2
#include "bloom.h"
3
#include "hex.h"
4
#include "test-tool.h"
t/helper/test-example-decorate.c
+1
-1
@@ -1,5 +1,5 @@
1
#include "test-tool.h"
2
-#include "cache.h"
2
+#include "git-compat-util.h"
3
#include "object.h"
4
#include "decorate.h"
5
worktree.h
-1
@@ -1,7 +1,6 @@
1
#ifndef WORKTREE_H
2
#define WORKTREE_H
3
4
-#include "cache.h"
4
#include "refs.h"
5
6
struct strbuf;