git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 04/16] treewide: remove unnecessary cache.h inclusion from several sources

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Mar 21, 2023, 06:25 UTC
Message-ID
<95b86aecb4391bf9767a1308267e18cc55c2fa5f.1679379971.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1493.v2.git.1679379968.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

A number of files were apparently including cache.h solely to get gettext.h. By making those files explicitly include gettext.h, we can already drop the include of cache.h in these files. On top of that, there were some files using cache.h that didn't need to for any reason. Remove these unnecessary includes.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 compat/linux/procinfo.c        | 2 +-
 compat/simple-ipc/ipc-shared.c | 2 +-
 connected.c                    | 2 +-
 grep.c                         | 2 +-
 negotiator/default.c           | 2 +-
 negotiator/skipping.c          | 2 +-
 notes-cache.c                  | 2 +-
 patch-ids.c                    | 2 +-
 reflog.c                       | 2 +-
 refs/iterator.c                | 2 +-
 replace-object.c               | 2 +-
 t/helper/test-hash.c           | 1 -
 xdiff-interface.c              | 2 +-
 13 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/compat/linux/procinfo.c b/compat/linux/procinfo.c
index bc2f9382a17..4bb2d66227b 100644
--- a/compat/linux/procinfo.c
+++ b/compat/linux/procinfo.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 
 #include "strbuf.h"
 #include "strvec.h"
diff --git a/compat/simple-ipc/ipc-shared.c b/compat/simple-ipc/ipc-shared.c
index 1b9d359ab68..e5e1dda8ccd 100644
--- a/compat/simple-ipc/ipc-shared.c
+++ b/compat/simple-ipc/ipc-shared.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "simple-ipc.h"
 #include "strbuf.h"
 #include "pkt-line.h"
diff --git a/connected.c b/connected.c
index a4c0aece757..669bc4e8d69 100644
--- a/connected.c
+++ b/connected.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/grep.c b/grep.c
index febb076a7e6..bb8796a829f 100644
--- a/grep.c
+++ b/grep.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "gettext.h"
 #include "grep.h"
diff --git a/negotiator/default.c b/negotiator/default.c
index b7e79feaf04..5dd553a1fe3 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "default.h"
 #include "../commit.h"
 #include "../fetch-negotiator.h"
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index 264acf8bbea..4157c4d72f5 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "skipping.h"
 #include "../commit.h"
 #include "../fetch-negotiator.h"
diff --git a/notes-cache.c b/notes-cache.c
index 9dfd251a815..01a918c925e 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "notes-cache.h"
 #include "object-store.h"
 #include "repository.h"
diff --git a/patch-ids.c b/patch-ids.c
index a4473a88fa2..19af7bee984 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "diff.h"
 #include "commit.h"
 #include "hash-lookup.h"
diff --git a/reflog.c b/reflog.c
index d1c39374318..4e121e449d1 100644
--- a/reflog.c
+++ b/reflog.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "object-store.h"
 #include "reflog.h"
diff --git a/refs/iterator.c b/refs/iterator.c
index c9fd0bcaf90..6b680f610ef 100644
--- a/refs/iterator.c
+++ b/refs/iterator.c
@@ -3,7 +3,7 @@
  * documentation about the design and use of reference iterators.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "refs.h"
 #include "refs/refs-internal.h"
 #include "iterator.h"
diff --git a/replace-object.c b/replace-object.c
index 9e30e0362ba..e98825d5852 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "oidmap.h"
diff --git a/t/helper/test-hash.c b/t/helper/test-hash.c
index 016248106a7..45d829c908f 100644
--- a/t/helper/test-hash.c
+++ b/t/helper/test-hash.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 
 int cmd_hash_impl(int ac, const char **av, int algo)
diff --git a/xdiff-interface.c b/xdiff-interface.c
index 5baf6ceb947..356356afe71 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "hex.h"
 #include "object-store.h"
-- 
gitgitgadget
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 23 of 37 in “Header cleanups”
  1. 00/16 Header cleanupsElijah Newren via GitGitGadget, Mar 19, 2023
  2. 03/16 treewide: remove unnecessary inclusion of gettext.hElijah Newren via GitGitGadget, Mar 19, 2023
  3. 05/16 environment: move comment_line_char from cache.hElijah Newren via GitGitGadget, Mar 19, 2023
  4. 01/16 treewide: remove unnecessary cache.h inclusion from a few headersElijah Newren via GitGitGadget, Mar 19, 2023
  5. 04/16 treewide: remove unnecessary cache.h inclusion from several sourcesElijah Newren via GitGitGadget, Mar 19, 2023
  6. 07/16 cache.h: remove expand_user_path()Elijah Newren via GitGitGadget, Mar 19, 2023
  7. 06/16 abspath.h: move absolute path functions from cache.hElijah Newren via GitGitGadget, Mar 19, 2023
  8. 08/16 path.h: move function declarations for path.c functions from cache.hElijah Newren via GitGitGadget, Mar 19, 2023
  9. 02/16 treewide: be explicit about dependence on gettext.hElijah Newren via GitGitGadget, Mar 19, 2023
  10. 10/16 treewide: remove unnecessary includes of cache.hElijah Newren via GitGitGadget, Mar 19, 2023
  11. 12/16 treewide: remove cache.h inclusion due to environment.h changesElijah Newren via GitGitGadget, Mar 19, 2023
  12. 09/16 wrapper.h: move declarations for wrapper.c functions from cache.hElijah Newren via GitGitGadget, Mar 19, 2023
  13. 14/16 treewide: remove cache.h inclusion due to setup.h changesElijah Newren via GitGitGadget, Mar 19, 2023
  14. 15/16 write-or-die.h: move declarations for write-or-die.c functions from cache.hElijah Newren via GitGitGadget, Mar 19, 2023
  15. 16/16 csum-file.h: remove unnecessary inclusion of cache.hElijah Newren via GitGitGadget, Mar 19, 2023
  16. 11/16 environment.h: move declarations for environment.c functions from cache.hElijah Newren via GitGitGadget, Mar 19, 2023
  17. 13/16 setup.h: move declarations for setup.c functions from cache.hElijah Newren via GitGitGadget, Mar 19, 2023
  18. Ævar Arnfjörð BjarmasonMar 20, 2023
  19. Elijah NewrenMar 20, 2023
  20. 00/16 Header cleanupsElijah Newren via GitGitGadget, Mar 21, 2023
  21. 01/16 treewide: remove unnecessary cache.h inclusion from a few headersElijah Newren via GitGitGadget, Mar 21, 2023
  22. 03/16 treewide: remove unnecessary inclusion of gettext.hElijah Newren via GitGitGadget, Mar 21, 2023
  23. 04/16 treewide: remove unnecessary cache.h inclusion from several sourcesElijah Newren via GitGitGadget, Mar 21, 2023
  24. 05/16 environment: move comment_line_char from cache.hElijah Newren via GitGitGadget, Mar 21, 2023
  25. 07/16 cache.h: remove expand_user_path()Elijah Newren via GitGitGadget, Mar 21, 2023
  26. 06/16 abspath.h: move absolute path functions from cache.hElijah Newren via GitGitGadget, Mar 21, 2023
  27. 08/16 path.h: move function declarations for path.c functions from cache.hElijah Newren via GitGitGadget, Mar 21, 2023
  28. 10/16 treewide: remove unnecessary includes of cache.hElijah Newren via GitGitGadget, Mar 21, 2023
  29. 12/16 treewide: remove cache.h inclusion due to environment.h changesElijah Newren via GitGitGadget, Mar 21, 2023
  30. 09/16 wrapper.h: move declarations for wrapper.c functions from cache.hElijah Newren via GitGitGadget, Mar 21, 2023
  31. 11/16 environment.h: move declarations for environment.c functions from cache.hElijah Newren via GitGitGadget, Mar 21, 2023
  32. 02/16 treewide: be explicit about dependence on gettext.hElijah Newren via GitGitGadget, Mar 21, 2023
  33. 14/16 treewide: remove cache.h inclusion due to setup.h changesElijah Newren via GitGitGadget, Mar 21, 2023
  34. 15/16 write-or-die.h: move declarations for write-or-die.c functions from cache.hElijah Newren via GitGitGadget, Mar 21, 2023
  35. 16/16 csum-file.h: remove unnecessary inclusion of cache.hElijah Newren via GitGitGadget, Mar 21, 2023
  36. 13/16 setup.h: move declarations for setup.c functions from cache.hElijah Newren via GitGitGadget, Mar 21, 2023
  37. Jonathan TanMar 21, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.