git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Emily Shaffer <nasamuffin@google.com>,
	Derrick Stolee <derrickstolee@github.com>,
	Elijah Newren <newren@gmail.com>,
	Elijah Newren <newren@gmail.com>,
	Elijah Newren <newren@gmail.com>
Subject: [PATCH v2 11/17] object.h: stop depending on cache.h; make cache.h depend on object.h
Date: Fri, 24 Feb 2023 00:09:30 +0000	[thread overview]
Message-ID: <1636615ca73c0a9999a7ada6be08c2c0743698a0.1677197378.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1485.v2.git.1677197376.gitgitgadget@gmail.com>

From: Elijah Newren <newren@gmail.com>

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>
---
 alloc.c                          |  2 +-
 blame.h                          |  1 -
 blob.c                           |  2 +-
 cache-tree.h                     |  1 -
 cache.h                          | 21 +--------------------
 diff-merges.c                    |  1 +
 diff.h                           |  2 +-
 diffcore-delta.c                 |  2 +-
 fsck.h                           |  1 +
 help.c                           |  1 +
 list-objects-filter-options.h    |  3 ++-
 negotiator/noop.c                |  2 +-
 object.h                         | 22 +++++++++++++++++++++-
 shallow.h                        |  2 ++
 t/helper/test-bloom.c            |  2 +-
 t/helper/test-example-decorate.c |  2 +-
 worktree.h                       |  1 -
 17 files changed, 36 insertions(+), 32 deletions(-)

diff --git a/alloc.c b/alloc.c
index 27f697e4c87..2886aa93543 100644
--- 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 38bde535b3d..b60d1d81e30 100644
--- 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 8f83523b0cd..888e28a5594 100644
--- 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"
diff --git a/cache-tree.h b/cache-tree.h
index bd97caa07b0..faae88be63c 100644
--- a/cache-tree.h
+++ b/cache-tree.h
@@ -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 4e0d9bccc06..d0e105ec58f 100644
--- 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 :
diff --git a/diff-merges.c b/diff-merges.c
index faa7bc73a34..ec97616db1d 100644
--- a/diff-merges.c
+++ b/diff-merges.c
@@ -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 41eb2c3d428..b90036f5294 100644
--- 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,
diff --git a/diffcore-delta.c b/diffcore-delta.c
index 18d8f766d70..c30b56e983b 100644
--- a/diffcore-delta.c
+++ b/diffcore-delta.c
@@ -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 668330880ef..e17730e9da9 100644
--- 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 5f84a50b948..216777d2bf4 100644
--- 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"
diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h
index 1fe393f4473..ef03b45132e 100644
--- a/list-objects-filter-options.h
+++ b/list-objects-filter-options.h
@@ -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.
diff --git a/negotiator/noop.c b/negotiator/noop.c
index 60569b83501..7b729376867 100644
--- a/negotiator/noop.c
+++ b/negotiator/noop.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "noop.h"
 #include "../commit.h"
 #include "../fetch-negotiator.h"
diff --git a/object.h b/object.h
index 31ebe114585..fc45b158da0 100644
--- 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.
  */
diff --git a/shallow.h b/shallow.h
index aba6ff58294..e9ca7e4bc80 100644
--- 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);
diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c
index 787fd524557..127f134a2a6 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "bloom.h"
 #include "hex.h"
 #include "test-tool.h"
diff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c
index b9d1200eb98..7c7fc8efc13 100644
--- a/t/helper/test-example-decorate.c
+++ b/t/helper/test-example-decorate.c
@@ -1,5 +1,5 @@
 #include "test-tool.h"
-#include "cache.h"
+#include "git-compat-util.h"
 #include "object.h"
 #include "decorate.h"
 
diff --git a/worktree.h b/worktree.h
index 9dcea6fc8c1..2baeca2a8a6 100644
--- a/worktree.h
+++ b/worktree.h
@@ -1,7 +1,6 @@
 #ifndef WORKTREE_H
 #define WORKTREE_H
 
-#include "cache.h"
 #include "refs.h"
 
 struct strbuf;
-- 
gitgitgadget


  parent reply	other threads:[~2023-02-24  0:10 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-23  8:05 [PATCH 00/16] Header cleanups Elijah Newren via GitGitGadget
2023-02-23  8:05 ` [PATCH 01/16] treewide: ensure one of the appropriate headers is sourced first Elijah Newren via GitGitGadget
2023-02-23  8:05 ` [PATCH 02/16] treewide: remove unnecessary git-compat-util.h includes in headers Elijah Newren via GitGitGadget
2023-02-23 13:52   ` Derrick Stolee
2023-02-23 18:13     ` Elijah Newren
2023-02-23 19:35   ` Junio C Hamano
2023-02-23 19:53     ` Elijah Newren
2023-02-23 22:07       ` Junio C Hamano
2023-02-23 23:41         ` Elijah Newren
2023-02-23  8:05 ` [PATCH 03/16] treewide: remove unnecessary cache.h includes Elijah Newren via GitGitGadget
2023-02-23  8:05 ` [PATCH 04/16] treewide: remove unnecessary cache.h includes in source files Elijah Newren via GitGitGadget
2023-02-23 13:57   ` Derrick Stolee
2023-02-23  8:05 ` [PATCH 05/16] alloc.h: move ALLOC_GROW() functions from cache.h Elijah Newren via GitGitGadget
2023-02-23 14:06   ` Derrick Stolee
2023-02-23 18:22     ` Elijah Newren
2023-02-23 19:40     ` Junio C Hamano
2023-02-23 19:39   ` Junio C Hamano
2023-02-23  8:05 ` [PATCH 06/16] hash.h: move some oid-related declarations " Elijah Newren via GitGitGadget
2023-02-23 14:08   ` Derrick Stolee
2023-02-23 18:25     ` Elijah Newren
2023-02-24 23:55   ` Jonathan Tan
2023-02-23  8:05 ` [PATCH 07/16] hex.h: move some hex-related " Elijah Newren via GitGitGadget
2023-02-23 14:11   ` Derrick Stolee
2023-02-23 19:31     ` Elijah Newren
2023-02-23  8:05 ` [PATCH 08/16] pretty.h: move has_non_ascii() declaration from commit.h Elijah Newren via GitGitGadget
2023-02-23  8:05 ` [PATCH 09/16] ident.h: move ident-related declarations out of cache.h Elijah Newren via GitGitGadget
2023-02-23  8:05 ` [PATCH 10/16] object.h: stop depending on cache.h; make cache.h depend on object.h Elijah Newren via GitGitGadget
2023-02-23 14:17   ` Derrick Stolee
2023-02-23 19:55     ` Elijah Newren
2023-02-23  8:05 ` [PATCH 11/16] dir.h: refactor to no longer need to include cache.h Elijah Newren via GitGitGadget
2023-02-23  8:05 ` [PATCH 12/16] object-store.h: move struct object_info from cache.h Elijah Newren via GitGitGadget
2023-02-23 14:20   ` Derrick Stolee
2023-02-23 19:55     ` Elijah Newren
2023-02-23  8:05 ` [PATCH 13/16] replace-object.h: move read_replace_refs declaration from cache.h to here Elijah Newren via GitGitGadget
2023-02-23  8:05 ` [PATCH 14/16] treewide: replace cache.h with more direct headers, where possible Elijah Newren via GitGitGadget
2023-02-23  8:05 ` [PATCH 15/16] Remove unnecessary includes of builtin.h Elijah Newren via GitGitGadget
2023-02-23  8:05 ` [PATCH 16/16] diff.h: remove unnecessary include of object.h Elijah Newren via GitGitGadget
2023-02-23 14:27 ` [PATCH 00/16] Header cleanups Derrick Stolee
2023-02-24  0:09 ` [PATCH v2 00/17] " Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 01/17] treewide: ensure one of the appropriate headers is sourced first Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 02/17] treewide: remove unnecessary git-compat-util.h includes in headers Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 03/17] treewide: remove unnecessary cache.h includes Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 04/17] treewide: remove unnecessary cache.h includes in source files Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 05/17] alloc.h: move ALLOC_GROW() functions from cache.h Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 06/17] hash.h: move some oid-related declarations " Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 07/17] hex.h: move some hex-related " Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 08/17] cache.h: remove dependence on hex.h; make other files include it explicitly Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 09/17] pretty.h: move has_non_ascii() declaration from commit.h Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 10/17] ident.h: move ident-related declarations out of cache.h Elijah Newren via GitGitGadget
2023-02-24  0:09   ` Elijah Newren via GitGitGadget [this message]
2023-02-24  0:09   ` [PATCH v2 12/17] dir.h: refactor to no longer need to include cache.h Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 13/17] object-store.h: move struct object_info from cache.h Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 14/17] replace-object.h: move read_replace_refs declaration from cache.h to here Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 15/17] treewide: replace cache.h with more direct headers, where possible Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 16/17] Remove unnecessary includes of builtin.h Elijah Newren via GitGitGadget
2023-02-24  0:09   ` [PATCH v2 17/17] diff.h: remove unnecessary include of object.h Elijah Newren via GitGitGadget
2023-02-24 14:03   ` [PATCH v2 00/17] Header cleanups Johannes Schindelin
2023-02-25  0:10   ` Jonathan Tan
2023-02-25  0:57     ` Elijah Newren
2023-02-27 13:51   ` Derrick Stolee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1636615ca73c0a9999a7ada6be08c2c0743698a0.1677197378.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=nasamuffin@google.com \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).