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

[PATCH 02/16] treewide: remove unnecessary git-compat-util.h includes in headers

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 23, 2023, 08:05 UTC
Message-ID
<adafa655432dd13d1c727522377ac9a4b515b76a.1677139521.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1485.git.1677139521.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

Since git-compat-util.h needs to be included first in C files, having it appear in header files is unnecessary. More importantly, having it included in header files seems to lead to folks leaving it out of C files, which makes it harder to verify that the rule is being followed. Remove it from header files, other than the ones that have been approved as alternate first includes.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 advice.h                               | 2 --
 cbtree.h                               | 2 --
 chunk-format.h                         | 1 -
 commit-graph.h                         | 1 -
 commit-slab-impl.h                     | 2 --
 compat/fsmonitor/fsm-ipc-win32.c       | 1 +
 compat/fsmonitor/fsm-settings-darwin.c | 1 +
 hash.h                                 | 1 -
 pack-mtimes.h                          | 2 --
 pkt-line.h                             | 1 -
 repository.h                           | 1 -
 sub-process.h                          | 1 -
 trace.h                                | 1 -
 13 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/advice.h b/advice.h
index 07e0f76833e..3e1b48bf68d 100644
--- a/advice.h
+++ b/advice.h
@@ -1,8 +1,6 @@
 #ifndef ADVICE_H
 #define ADVICE_H
 
-#include "git-compat-util.h"
-
 struct string_list;
 
 /*
diff --git a/cbtree.h b/cbtree.h
index 0be14fb7ee4..43193abdda2 100644
--- a/cbtree.h
+++ b/cbtree.h
@@ -14,8 +14,6 @@
 #ifndef CBTREE_H
 #define CBTREE_H
 
-#include "git-compat-util.h"
-
 struct cb_node;
 struct cb_node {
 	struct cb_node *child[2];
diff --git a/chunk-format.h b/chunk-format.h
index 7885aa08487..025c38f938e 100644
--- a/chunk-format.h
+++ b/chunk-format.h
@@ -1,7 +1,6 @@
 #ifndef CHUNK_FORMAT_H
 #define CHUNK_FORMAT_H
 
-#include "git-compat-util.h"
 #include "hash.h"
 
 struct hashfile;
diff --git a/commit-graph.h b/commit-graph.h
index 37faee6b66d..bb88bec7aa3 100644
--- a/commit-graph.h
+++ b/commit-graph.h
@@ -1,7 +1,6 @@
 #ifndef COMMIT_GRAPH_H
 #define COMMIT_GRAPH_H
 
-#include "git-compat-util.h"
 #include "object-store.h"
 #include "oidset.h"
 
diff --git a/commit-slab-impl.h b/commit-slab-impl.h
index 557738df271..4a414ee905d 100644
--- a/commit-slab-impl.h
+++ b/commit-slab-impl.h
@@ -1,8 +1,6 @@
 #ifndef COMMIT_SLAB_IMPL_H
 #define COMMIT_SLAB_IMPL_H
 
-#include "git-compat-util.h"
-
 #define implement_static_commit_slab(slabname, elemtype) \
 	implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static)
 
diff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c
index e08c505c148..c9536dfb666 100644
--- a/compat/fsmonitor/fsm-ipc-win32.c
+++ b/compat/fsmonitor/fsm-ipc-win32.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
 #include "config.h"
 #include "fsmonitor-ipc.h"
 
diff --git a/compat/fsmonitor/fsm-settings-darwin.c b/compat/fsmonitor/fsm-settings-darwin.c
index 6abbc7af3ab..58b623fbb9a 100644
--- a/compat/fsmonitor/fsm-settings-darwin.c
+++ b/compat/fsmonitor/fsm-settings-darwin.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
 #include "config.h"
 #include "fsmonitor.h"
 #include "fsmonitor-ipc.h"
diff --git a/hash.h b/hash.h
index 36b64165fc9..351afc2ce3b 100644
--- a/hash.h
+++ b/hash.h
@@ -1,7 +1,6 @@
 #ifndef HASH_H
 #define HASH_H
 
-#include "git-compat-util.h"
 #include "repository.h"
 
 #if defined(SHA1_APPLE)
diff --git a/pack-mtimes.h b/pack-mtimes.h
index cc957b3e852..107327cec0b 100644
--- a/pack-mtimes.h
+++ b/pack-mtimes.h
@@ -1,8 +1,6 @@
 #ifndef PACK_MTIMES_H
 #define PACK_MTIMES_H
 
-#include "git-compat-util.h"
-
 #define MTIMES_SIGNATURE 0x4d544d45 /* "MTME" */
 #define MTIMES_VERSION 1
 
diff --git a/pkt-line.h b/pkt-line.h
index 79c538b99e4..8e9846f3151 100644
--- a/pkt-line.h
+++ b/pkt-line.h
@@ -1,7 +1,6 @@
 #ifndef PKTLINE_H
 #define PKTLINE_H
 
-#include "git-compat-util.h"
 #include "strbuf.h"
 #include "sideband.h"
 
diff --git a/repository.h b/repository.h
index e8c67ffe165..15a8afc5fb5 100644
--- a/repository.h
+++ b/repository.h
@@ -1,7 +1,6 @@
 #ifndef REPOSITORY_H
 #define REPOSITORY_H
 
-#include "git-compat-util.h"
 #include "path.h"
 
 struct config_set;
diff --git a/sub-process.h b/sub-process.h
index e85f21fa1a7..6a61638a8ac 100644
--- a/sub-process.h
+++ b/sub-process.h
@@ -1,7 +1,6 @@
 #ifndef SUBPROCESS_H
 #define SUBPROCESS_H
 
-#include "git-compat-util.h"
 #include "hashmap.h"
 #include "run-command.h"
 
diff --git a/trace.h b/trace.h
index 4e771f86ac2..1a75824b15e 100644
--- a/trace.h
+++ b/trace.h
@@ -1,7 +1,6 @@
 #ifndef TRACE_H
 #define TRACE_H
 
-#include "git-compat-util.h"
 #include "strbuf.h"
 
 /**
-- 
gitgitgadget
Previous: Elijah Newren via GitGitGadgetNext: Derrick Stolee
Message 3 of 60 in “Header cleanups”
  1. 00/16 Header cleanupsElijah Newren via GitGitGadget, Feb 23, 2023
  2. 01/16 treewide: ensure one of the appropriate headers is sourced firstElijah Newren via GitGitGadget, Feb 23, 2023
  3. 02/16 treewide: remove unnecessary git-compat-util.h includes in headersElijah Newren via GitGitGadget, Feb 23, 2023
  4. Derrick StoleeFeb 23, 2023
  5. Elijah NewrenFeb 23, 2023
  6. Junio C HamanoFeb 23, 2023
  7. Elijah NewrenFeb 23, 2023
  8. Junio C HamanoFeb 23, 2023
  9. Elijah NewrenFeb 23, 2023
  10. 03/16 treewide: remove unnecessary cache.h includesElijah Newren via GitGitGadget, Feb 23, 2023
  11. 04/16 treewide: remove unnecessary cache.h includes in source filesElijah Newren via GitGitGadget, Feb 23, 2023
  12. Derrick StoleeFeb 23, 2023
  13. 06/16 hash.h: move some oid-related declarations from cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  14. Derrick StoleeFeb 23, 2023
  15. Elijah NewrenFeb 23, 2023
  16. Jonathan TanFeb 24, 2023
  17. 05/16 alloc.h: move ALLOC_GROW() functions from cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  18. Derrick StoleeFeb 23, 2023
  19. Elijah NewrenFeb 23, 2023
  20. Junio C HamanoFeb 23, 2023
  21. Junio C HamanoFeb 23, 2023
  22. 07/16 hex.h: move some hex-related declarations from cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  23. Derrick StoleeFeb 23, 2023
  24. Elijah NewrenFeb 23, 2023
  25. 09/16 ident.h: move ident-related declarations out of cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  26. 08/16 pretty.h: move has_non_ascii() declaration from commit.hElijah Newren via GitGitGadget, Feb 23, 2023
  27. 10/16 object.h: stop depending on cache.h; make cache.h depend on object.hElijah Newren via GitGitGadget, Feb 23, 2023
  28. Derrick StoleeFeb 23, 2023
  29. Elijah NewrenFeb 23, 2023
  30. 11/16 dir.h: refactor to no longer need to include cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  31. 12/16 object-store.h: move struct object_info from cache.hElijah Newren via GitGitGadget, Feb 23, 2023
  32. Derrick StoleeFeb 23, 2023
  33. Elijah NewrenFeb 23, 2023
  34. 13/16 replace-object.h: move read_replace_refs declaration from cache.h to hereElijah Newren via GitGitGadget, Feb 23, 2023
  35. 15/16 Remove unnecessary includes of builtin.hElijah Newren via GitGitGadget, Feb 23, 2023
  36. 14/16 treewide: replace cache.h with more direct headers, where possibleElijah Newren via GitGitGadget, Feb 23, 2023
  37. 16/16 diff.h: remove unnecessary include of object.hElijah Newren via GitGitGadget, Feb 23, 2023
  38. Derrick StoleeFeb 23, 2023
  39. 00/17 Header cleanupsElijah Newren via GitGitGadget, Feb 24, 2023
  40. 01/17 treewide: ensure one of the appropriate headers is sourced firstElijah Newren via GitGitGadget, Feb 24, 2023
  41. 02/17 treewide: remove unnecessary git-compat-util.h includes in headersElijah Newren via GitGitGadget, Feb 24, 2023
  42. 03/17 treewide: remove unnecessary cache.h includesElijah Newren via GitGitGadget, Feb 24, 2023
  43. 04/17 treewide: remove unnecessary cache.h includes in source filesElijah Newren via GitGitGadget, Feb 24, 2023
  44. 06/17 hash.h: move some oid-related declarations from cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  45. 07/17 hex.h: move some hex-related declarations from cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  46. 09/17 pretty.h: move has_non_ascii() declaration from commit.hElijah Newren via GitGitGadget, Feb 24, 2023
  47. 05/17 alloc.h: move ALLOC_GROW() functions from cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  48. 10/17 ident.h: move ident-related declarations out of cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  49. 11/17 object.h: stop depending on cache.h; make cache.h depend on object.hElijah Newren via GitGitGadget, Feb 24, 2023
  50. 12/17 dir.h: refactor to no longer need to include cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  51. 13/17 object-store.h: move struct object_info from cache.hElijah Newren via GitGitGadget, Feb 24, 2023
  52. 15/17 treewide: replace cache.h with more direct headers, where possibleElijah Newren via GitGitGadget, Feb 24, 2023
  53. 14/17 replace-object.h: move read_replace_refs declaration from cache.h to hereElijah Newren via GitGitGadget, Feb 24, 2023
  54. 16/17 Remove unnecessary includes of builtin.hElijah Newren via GitGitGadget, Feb 24, 2023
  55. 08/17 cache.h: remove dependence on hex.h; make other files include it explicitlyElijah Newren via GitGitGadget, Feb 24, 2023
  56. 17/17 diff.h: remove unnecessary include of object.hElijah Newren via GitGitGadget, Feb 24, 2023
  57. Johannes SchindelinFeb 24, 2023
  58. Jonathan TanFeb 25, 2023
  59. Elijah NewrenFeb 25, 2023
  60. Derrick StoleeFeb 27, 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.