Subject: [PATCH 01/16] treewide: remove unnecessary cache.h inclusion from a few headers

From: "Elijah Newren via GitGitGadget" <[email-masked]>
Date: Sun, 19 Mar 2023 06:27:47 +0000

From: Elijah Newren <[email-masked]>

Ever since a64215b6cd ("object.h: stop depending on cache.h; make
cache.h depend on object.h", 2023-02-24), we have a few headers that
could have replaced their include of cache.h with an include of
object.h.  Make that change now.

Some C files had to start including cache.h after this change (or some
smaller header it had brought in), because the C files were depending
on things from cache.h but were only formerly implicitly getting
cache.h through one of these headers being modified in this patch.

Signed-off-by: Elijah Newren <[email-masked]>
---
 bulk-checkin.h              | 2 +-
 bundle.h                    | 1 -
 cache-tree.c                | 2 +-
 config.c                    | 2 +-
 fmt-merge-msg.c             | 2 +-
 fsck.c                      | 2 +-
 http-backend.c              | 2 +-
 pack-mtimes.c               | 2 +-
 packfile.h                  | 4 +++-
 prune-packed.c              | 2 +-
 ref-filter.c                | 2 +-
 refs.c                      | 2 +-
 refs.h                      | 1 -
 refs/packed-backend.c       | 2 +-
 refspec.c                   | 1 +
 remote.c                    | 2 +-
 server-info.c               | 2 +-
 shallow.c                   | 2 +-
 strbuf.c                    | 2 +-
 streaming.h                 | 4 +++-
 submodule.c                 | 2 +-
 t/helper/test-bundle-uri.c  | 1 +
 t/helper/test-fast-rebase.c | 2 +-
 t/helper/test-pack-mtimes.c | 2 +-
 t/helper/test-reach.c       | 1 +
 transport.c                 | 2 +-
 transport.h                 | 1 -
 worktree.c                  | 2 +-
 28 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/bulk-checkin.h b/bulk-checkin.h
index 8281b9cb159..48fe9a6e917 100644
--- a/bulk-checkin.h
+++ b/bulk-checkin.h
@@ -4,7 +4,7 @@
 #ifndef BULK_CHECKIN_H
 #define BULK_CHECKIN_H
 
-#include "cache.h"
+#include "object.h"
 
 void prepare_loose_object_bulk_checkin(void);
 void fsync_loose_object_bulk_checkin(int fd, const char *filename);
diff --git a/bundle.h b/bundle.h
index 9f2bd733a6a..021adbdcbb3 100644
--- a/bundle.h
+++ b/bundle.h
@@ -2,7 +2,6 @@
 #define BUNDLE_H
 
 #include "strvec.h"
-#include "cache.h"
 #include "string-list.h"
 #include "list-objects-filter-options.h"
 
diff --git a/cache-tree.c b/cache-tree.c
index 9d46ecef091..6f899beb041 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "hex.h"
 #include "lockfile.h"
diff --git a/config.c b/config.c
index d0aff55fa66..983c45fc37b 100644
--- a/config.c
+++ b/config.c
@@ -5,7 +5,7 @@
  * Copyright (C) Johannes Schindelin, 2005
  *
  */
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "date.h"
 #include "branch.h"
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 24cc44bdbc9..c870cb95b9d 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "config.h"
 #include "refs.h"
diff --git a/fsck.c b/fsck.c
index 871c0a9a252..70e12497878 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/http-backend.c b/http-backend.c
index 9cfc6f25414..7e7c19e66b3 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "config.h"
 #include "hex.h"
diff --git a/pack-mtimes.c b/pack-mtimes.c
index 0f9785fc5e4..cd92fc1d86c 100644
--- a/pack-mtimes.c
+++ b/pack-mtimes.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "pack-mtimes.h"
 #include "object-store.h"
 #include "packfile.h"
diff --git a/packfile.h b/packfile.h
index a3f6723857b..648be62bf22 100644
--- a/packfile.h
+++ b/packfile.h
@@ -1,11 +1,13 @@
 #ifndef PACKFILE_H
 #define PACKFILE_H
 
-#include "cache.h"
+#include "object.h"
 #include "oidset.h"
 
 /* in object-store.h */
 struct packed_git;
+struct pack_entry;
+struct pack_window;
 struct object_info;
 
 /*
diff --git a/prune-packed.c b/prune-packed.c
index d2813f6a405..e02f466c2ee 100644
--- a/prune-packed.c
+++ b/prune-packed.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "object-store.h"
 #include "packfile.h"
 #include "progress.h"
diff --git a/ref-filter.c b/ref-filter.c
index ed802778da7..38141bce8db 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "hex.h"
 #include "parse-options.h"
diff --git a/refs.c b/refs.c
index 53240bcc07b..4e5cc73fb10 100644
--- a/refs.c
+++ b/refs.c
@@ -2,7 +2,7 @@
  * The backend-independent part of the reference module.
  */
 
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "config.h"
 #include "hashmap.h"
diff --git a/refs.h b/refs.h
index 935cdd1ece3..5741b69d0d1 100644
--- a/refs.h
+++ b/refs.h
@@ -1,7 +1,6 @@
 #ifndef REFS_H
 #define REFS_H
 
-#include "cache.h"
 #include "commit.h"
 
 struct object_id;
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index b665d0f7d9b..6f975185995 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1,4 +1,4 @@
-#include "../git-compat-util.h"
+#include "../cache.h"
 #include "../alloc.h"
 #include "../config.h"
 #include "../hex.h"
diff --git a/refspec.c b/refspec.c
index 28d90911aa5..7b5c305514d 100644
--- a/refspec.c
+++ b/refspec.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "alloc.h"
+#include "gettext.h"
 #include "hex.h"
 #include "strvec.h"
 #include "refs.h"
diff --git a/remote.c b/remote.c
index b04e5da3383..2daddb85cb7 100644
--- a/remote.c
+++ b/remote.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "config.h"
 #include "hex.h"
diff --git a/server-info.c b/server-info.c
index 40436892023..78643377057 100644
--- a/server-info.c
+++ b/server-info.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "dir.h"
 #include "hex.h"
diff --git a/shallow.c b/shallow.c
index 1cbb05ba0e4..c5433a4fd30 100644
--- a/shallow.c
+++ b/shallow.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "hex.h"
 #include "repository.h"
diff --git a/strbuf.c b/strbuf.c
index 1c57ac6574f..8800830ebf8 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "hex.h"
 #include "refs.h"
diff --git a/streaming.h b/streaming.h
index 5e4e6acfd0d..bd27f59e576 100644
--- a/streaming.h
+++ b/streaming.h
@@ -3,10 +3,12 @@
  */
 #ifndef STREAMING_H
 #define STREAMING_H 1
-#include "cache.h"
+
+#include "object.h"
 
 /* opaque */
 struct git_istream;
+struct stream_filter;
 
 struct git_istream *open_istream(struct repository *, const struct object_id *,
 				 enum object_type *, unsigned long *,
diff --git a/submodule.c b/submodule.c
index 2a057c35b74..0baf97cf770 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "repository.h"
 #include "config.h"
diff --git a/t/helper/test-bundle-uri.c b/t/helper/test-bundle-uri.c
index b18e7603103..475058592d1 100644
--- a/t/helper/test-bundle-uri.c
+++ b/t/helper/test-bundle-uri.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "parse-options.h"
 #include "bundle-uri.h"
+#include "gettext.h"
 #include "strbuf.h"
 #include "string-list.h"
 #include "transport.h"
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index b1edb92a032..1e975df9041 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -12,7 +12,7 @@
 
 #define USE_THE_INDEX_VARIABLE
 #include "test-tool.h"
-
+#include "cache.h"
 #include "cache-tree.h"
 #include "commit.h"
 #include "hex.h"
diff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c
index f68b3761b68..0e53dee9e57 100644
--- a/t/helper/test-pack-mtimes.c
+++ b/t/helper/test-pack-mtimes.c
@@ -1,5 +1,5 @@
-#include "git-compat-util.h"
 #include "test-tool.h"
+#include "cache.h"
 #include "hex.h"
 #include "strbuf.h"
 #include "object-store.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index de8f26639d4..05d56267a9f 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -1,4 +1,5 @@
 #include "test-tool.h"
+#include "cache.h"
 #include "alloc.h"
 #include "commit.h"
 #include "commit-reach.h"
diff --git a/transport.c b/transport.c
index 906dbad5a08..80059124c0a 100644
--- a/transport.c
+++ b/transport.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "config.h"
 #include "hex.h"
diff --git a/transport.h b/transport.h
index 85150f504fb..6393cd9823c 100644
--- a/transport.h
+++ b/transport.h
@@ -1,7 +1,6 @@
 #ifndef TRANSPORT_H
 #define TRANSPORT_H
 
-#include "cache.h"
 #include "run-command.h"
 #include "remote.h"
 #include "list-objects-filter-options.h"
diff --git a/worktree.c b/worktree.c
index c99939a4d1f..9f8f3484ebd 100644
--- a/worktree.c
+++ b/worktree.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "repository.h"
 #include "refs.h"
-- 
gitgitgadget