Subject: [PATCH v2 22/24] treewide: remove double forward declaration of read_in_full

From: "Elijah Newren via GitGitGadget" <[email-masked]>
Date: Tue, 04 Apr 2023 01:22:26 +0000

From: Elijah Newren <[email-masked]>

cache.h's nature of a dumping ground of includes prevented it from
being included in some compat/ files, forcing us into a workaround
of having a double forward declaration of the read_in_full() function
(see commit 14086b0a13 ("compat/pread.c: Add a forward declaration to
fix a warning", 2007-11-17)).  Now that we have moved functions like
read_in_full() from cache.h to wrapper.h, and wrapper.h isn't littered
with unrelated and scary #defines, get rid of the extra forward
declaration and just have compat/pread.c include wrapper.h.

Signed-off-by: Elijah Newren <[email-masked]>
---
 builtin/clone.c       | 1 +
 bulk-checkin.c        | 1 +
 combine-diff.c        | 1 +
 compat/pread.c        | 1 +
 git-compat-util.h     | 6 ------
 grep.c                | 1 +
 pack-write.c          | 1 +
 path.c                | 1 +
 refs/packed-backend.c | 1 +
 send-pack.c           | 1 +
 setup.c               | 1 +
 upload-pack.c         | 1 +
 12 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index c7fdffb484c..4ed0a1d5aad 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -42,6 +42,7 @@
 #include "hook.h"
 #include "bundle.h"
 #include "bundle-uri.h"
+#include "wrapper.h"
 
 /*
  * Overall FIXMEs:
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 9192298db6a..d843279715c 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -17,6 +17,7 @@
 #include "packfile.h"
 #include "object-file.h"
 #include "object-store.h"
+#include "wrapper.h"
 
 static int odb_transaction_nesting;
 
diff --git a/combine-diff.c b/combine-diff.c
index cd5f39f22f4..f7e9fb57473 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -16,6 +16,7 @@
 #include "userdiff.h"
 #include "oid-array.h"
 #include "revision.h"
+#include "wrapper.h"
 
 static int compare_paths(const struct combine_diff_path *one,
 			  const struct diff_filespec *two)
diff --git a/compat/pread.c b/compat/pread.c
index 978cac4ec91..484e6d4c716 100644
--- a/compat/pread.c
+++ b/compat/pread.c
@@ -1,4 +1,5 @@
 #include "../git-compat-util.h"
+#include "../wrapper.h"
 
 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
 {
diff --git a/git-compat-util.h b/git-compat-util.h
index 1e6592624d0..4fb771f42a5 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -859,12 +859,6 @@ int git_lstat(const char *, struct stat *);
 #define pread git_pread
 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
 #endif
-/*
- * Forward decl that will remind us if its twin in cache.h changes.
- * This function is used in compat/pread.c.  But we can't include
- * cache.h there.
- */
-ssize_t read_in_full(int fd, void *buf, size_t count);
 
 #ifdef NO_SETENV
 #define setenv gitsetenv
diff --git a/grep.c b/grep.c
index bb8796a829f..d144b374894 100644
--- a/grep.c
+++ b/grep.c
@@ -11,6 +11,7 @@
 #include "commit.h"
 #include "quote.h"
 #include "help.h"
+#include "wrapper.h"
 
 static int grep_source_load(struct grep_source *gs);
 static int grep_source_is_binary(struct grep_source *gs,
diff --git a/pack-write.c b/pack-write.c
index d9b460fab4c..9c37121be31 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -10,6 +10,7 @@
 #include "oidmap.h"
 #include "pack-objects.h"
 #include "pack-revindex.h"
+#include "wrapper.h"
 
 void reset_pack_idx_option(struct pack_idx_option *opts)
 {
diff --git a/path.c b/path.c
index dff215ac693..7c1cd8182a8 100644
--- a/path.c
+++ b/path.c
@@ -18,6 +18,7 @@
 #include "object-store.h"
 #include "lockfile.h"
 #include "exec-cmd.h"
+#include "wrapper.h"
 
 static int get_st_mode_bits(const char *path, int *mode)
 {
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 1eba1015dd5..2333ed5a1f7 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -9,6 +9,7 @@
 #include "../iterator.h"
 #include "../lockfile.h"
 #include "../chdir-notify.h"
+#include "../wrapper.h"
 #include "../write-or-die.h"
 
 enum mmap_strategy {
diff --git a/send-pack.c b/send-pack.c
index 72ebb7b61ae..351037b07bc 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -14,6 +14,7 @@
 #include "quote.h"
 #include "transport.h"
 #include "version.h"
+#include "wrapper.h"
 #include "oid-array.h"
 #include "gpg-interface.h"
 #include "shallow.h"
diff --git a/setup.c b/setup.c
index a546da755f1..59abc16ba6d 100644
--- a/setup.c
+++ b/setup.c
@@ -12,6 +12,7 @@
 #include "promisor-remote.h"
 #include "quote.h"
 #include "trace2.h"
+#include "wrapper.h"
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
diff --git a/upload-pack.c b/upload-pack.c
index 0305fb2fbdc..e16dee783dd 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -32,6 +32,7 @@
 #include "commit-graph.h"
 #include "commit-reach.h"
 #include "shallow.h"
+#include "wrapper.h"
 #include "write-or-die.h"
 
 /* Remember to update object flag allocation in object.h */
-- 
gitgitgadget