]> git.ipfire.org Git - thirdparty/git.git/commitdiff
object.h: stop depending on cache.h; make cache.h depend on object.h
authorElijah Newren <newren@gmail.com>
Fri, 24 Feb 2023 00:09:30 +0000 (00:09 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Feb 2023 01:25:29 +0000 (17:25 -0800)
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>
17 files changed:
alloc.c
blame.h
blob.c
cache-tree.h
cache.h
diff-merges.c
diff.h
diffcore-delta.c
fsck.h
help.c
list-objects-filter-options.h
negotiator/noop.c
object.h
shallow.h
t/helper/test-bloom.c
t/helper/test-example-decorate.c
worktree.h

diff --git a/alloc.c b/alloc.c
index 27f697e4c87a05ef7cc847a17e83e14e9cfd2a4d..2886aa93543478f4bf221ca3e4a830a40f9baf42 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -8,7 +8,7 @@
  * up with maximal alignment because it doesn't know what the object alignment
  * for the new allocation is.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "object.h"
 #include "blob.h"
 #include "tree.h"
diff --git a/blame.h b/blame.h
index 38bde535b3d46461d0619bc68c852210693de571..b60d1d81e3032acc5df2191321202b13eecc81fe 100644 (file)
--- a/blame.h
+++ b/blame.h
@@ -1,7 +1,6 @@
 #ifndef BLAME_H
 #define BLAME_H
 
-#include "cache.h"
 #include "commit.h"
 #include "xdiff-interface.h"
 #include "revision.h"
diff --git a/blob.c b/blob.c
index 8f83523b0cde6dbf1b808b3dcf8ab1c1c23085f3..888e28a5594747bd263df0bb8f2179122bccb131 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "blob.h"
 #include "repository.h"
 #include "alloc.h"
index bd97caa07b08f6b5dc62f73485d93d232e179327..faae88be63c2ce012c700af3a88e02e165982a4e 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef CACHE_TREE_H
 #define CACHE_TREE_H
 
-#include "cache.h"
 #include "tree.h"
 #include "tree-walk.h"
 
diff --git a/cache.h b/cache.h
index 4e0d9bccc068f0701eeea7168b865b16a4e0bb2a..d0e105ec58ff549c7b51691b483beead4acf120b 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -14,6 +14,7 @@
 #include "pack-revindex.h"
 #include "hash.h"
 #include "path.h"
+#include "object.h"
 #include "oid-array.h"
 #include "repository.h"
 #include "mem-pool.h"
@@ -453,26 +454,6 @@ void prefetch_cache_entries(const struct index_state *istate,
 extern struct index_state the_index;
 #endif
 
-#define TYPE_BITS 3
-
-/*
- * Values in this enum (except those outside the 3 bit range) are part
- * of pack file format. See gitformat-pack(5) for more information.
- */
-enum object_type {
-       OBJ_BAD = -1,
-       OBJ_NONE = 0,
-       OBJ_COMMIT = 1,
-       OBJ_TREE = 2,
-       OBJ_BLOB = 3,
-       OBJ_TAG = 4,
-       /* 5 for future expansion */
-       OBJ_OFS_DELTA = 6,
-       OBJ_REF_DELTA = 7,
-       OBJ_ANY,
-       OBJ_MAX
-};
-
 static inline enum object_type object_type(unsigned int mode)
 {
        return S_ISDIR(mode) ? OBJ_TREE :
index faa7bc73a343a1eca1e28d920ab32980e0a2f730..ec97616db1dfaa0673945bb08a9f364b2d570db1 100644 (file)
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "diff-merges.h"
 
+#include "gettext.h"
 #include "revision.h"
 
 typedef void (*diff_merges_setup_func_t)(struct rev_info *);
diff --git a/diff.h b/diff.h
index 41eb2c3d428801130bc6ffe355cc723067689b85..b90036f52942ca7a740533e5f200345a20395928 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -8,6 +8,7 @@
 #include "pathspec.h"
 #include "object.h"
 #include "oidset.h"
+#include "strbuf.h"
 
 /**
  * The diff API is for programs that compare two sets of files (e.g. two trees,
@@ -71,7 +72,6 @@ struct oid_array;
 struct option;
 struct repository;
 struct rev_info;
-struct strbuf;
 struct userdiff_driver;
 
 typedef int (*pathchange_fn_t)(struct diff_options *options,
index 18d8f766d70108e868a5bb21ad6c45550bb8c34d..c30b56e983bda39e18eda24bb81608ae7a33942c 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "diff.h"
 #include "diffcore.h"
 
diff --git a/fsck.h b/fsck.h
index 668330880ef65f72ba4e9d38487152cc28c205a1..e17730e9da94053f39f1610e8cd81ab80bbf8a9f 100644 (file)
--- a/fsck.h
+++ b/fsck.h
@@ -1,6 +1,7 @@
 #ifndef GIT_FSCK_H
 #define GIT_FSCK_H
 
+#include "object.h"
 #include "oidset.h"
 
 enum fsck_msg_type {
diff --git a/help.c b/help.c
index 5f84a50b948ef84ca5df5127b4570f44ba9cb768..216777d2bf4bc7cdc78418cd90d2ed990e78c387 100644 (file)
--- a/help.c
+++ b/help.c
@@ -5,6 +5,7 @@
 #include "exec-cmd.h"
 #include "run-command.h"
 #include "levenshtein.h"
+#include "gettext.h"
 #include "help.h"
 #include "command-list.h"
 #include "string-list.h"
index 1fe393f447303a6d94abbd571a1ea83a1bfc7620..ef03b45132e87ae1f1951e86c5d38084c4467b76 100644 (file)
@@ -1,9 +1,10 @@
 #ifndef LIST_OBJECTS_FILTER_OPTIONS_H
 #define LIST_OBJECTS_FILTER_OPTIONS_H
 
-#include "cache.h"
+#include "object.h"
 #include "parse-options.h"
 #include "string-list.h"
+#include "strbuf.h"
 
 /*
  * The list of defined filters for list-objects.
index 60569b83501a0d789452a934fcabcfc7aa5b24e4..7b729376867afee47c76aaf74901aa19f3615804 100644 (file)
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "noop.h"
 #include "../commit.h"
 #include "../fetch-negotiator.h"
index 31ebe114585bb14cb95f4c74486635754d199955..fc45b158da095d750d9dc55b93282aabe997e7f1 100644 (file)
--- a/object.h
+++ b/object.h
@@ -1,7 +1,7 @@
 #ifndef OBJECT_H
 #define OBJECT_H
 
-#include "cache.h"
+#include "hash.h"
 
 struct buffer_slab;
 
@@ -81,6 +81,26 @@ struct object_array {
  */
 #define FLAG_BITS  28
 
+#define TYPE_BITS 3
+
+/*
+ * Values in this enum (except those outside the 3 bit range) are part
+ * of pack file format. See gitformat-pack(5) for more information.
+ */
+enum object_type {
+       OBJ_BAD = -1,
+       OBJ_NONE = 0,
+       OBJ_COMMIT = 1,
+       OBJ_TREE = 2,
+       OBJ_BLOB = 3,
+       OBJ_TAG = 4,
+       /* 5 for future expansion */
+       OBJ_OFS_DELTA = 6,
+       OBJ_REF_DELTA = 7,
+       OBJ_ANY,
+       OBJ_MAX
+};
+
 /*
  * The object type is stored in 3 bits.
  */
index aba6ff5829405647070c5b2a475318e2fd76282d..e9ca7e4bc80451a74dc10fb6d4e1a0b190dc4dcc 100644 (file)
--- a/shallow.h
+++ b/shallow.h
@@ -6,6 +6,8 @@
 #include "repository.h"
 #include "strbuf.h"
 
+struct oid_array;
+
 void set_alternate_shallow_file(struct repository *r, const char *path, int override);
 int register_shallow(struct repository *r, const struct object_id *oid);
 int unregister_shallow(const struct object_id *oid);
index 787fd5245570c635d631aefb6e89b54659e15171..127f134a2a6e4709b4bed08419b88961354a05e7 100644 (file)
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "bloom.h"
 #include "hex.h"
 #include "test-tool.h"
index b9d1200eb988e19f3f0a2c0aeed941a6eb44b9bb..7c7fc8efc13d458df6745fb44804c8f92b4a9a9c 100644 (file)
@@ -1,5 +1,5 @@
 #include "test-tool.h"
-#include "cache.h"
+#include "git-compat-util.h"
 #include "object.h"
 #include "decorate.h"
 
index 9dcea6fc8c1b4fcc387818967d2de99713bfb50b..2baeca2a8a602e57a734c3af1b514ecd94ec1eb3 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef WORKTREE_H
 #define WORKTREE_H
 
-#include "cache.h"
 #include "refs.h"
 
 struct strbuf;