summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2023-02-24 00:09:20 +0000
committerJunio C Hamano <gitster@pobox.com>2023-02-23 17:25:28 -0800
commit8bff5ca030d314d613e1ab58f07b27914d6dfd33 (patch)
tree41f3b9d47ebad2794acc9e9e2174ce9bf843ac80
parent06dd2baa8da4a73421b959ec026a43711b9d77f9 (diff)
downloadgit-8bff5ca030d314d613e1ab58f07b27914d6dfd33.tar.gz
treewide: ensure one of the appropriate headers is sourced first
We had several C files ignoring the rule to include one of the appropriate headers first; fix that. While at it, the rule in Documentation/CodingGuidelines about which header to include has also fallen out of sync, so update the wording to mention other allowed headers. Unfortunately, C files in reftable/ don't actually follow the previous or updated rule. If you follow the #include chain in its C files, reftable/system.h _tends_ to be first (i.e. record.c first includes record.h, which first includes basics.h, which first includees system.h), but not always (e.g. publicbasics.c includes another header first that does not include system.h). However, I'm going to punt on making actual changes to the C files in reftable/ since I do not want to risk bringing it out-of-sync with any version being used externally. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Documentation/CodingGuidelines8
-rw-r--r--cbtree.c1
-rw-r--r--compat/fsmonitor/fsm-ipc-win32.c1
-rw-r--r--compat/fsmonitor/fsm-settings-darwin.c1
-rw-r--r--diff-merges.c1
-rw-r--r--fmt-merge-msg.c1
-rw-r--r--oidtree.c1
-rw-r--r--oss-fuzz/fuzz-commit-graph.c1
-rw-r--r--oss-fuzz/fuzz-pack-headers.c1
-rw-r--r--oss-fuzz/fuzz-pack-idx.c1
-rw-r--r--prune-packed.c1
-rw-r--r--rebase.c1
-rw-r--r--refs/debug.c2
-rw-r--r--sub-process.c1
14 files changed, 19 insertions, 3 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 9d5c27807a..003393ed16 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -442,8 +442,12 @@ For C programs:
detail.
- The first #include in C files, except in platform specific compat/
- implementations, must be either "git-compat-util.h", "cache.h" or
- "builtin.h". You do not have to include more than one of these.
+ implementations and sha1dc/, must be either "git-compat-util.h" or
+ one of the approved headers that includes it first for you. (The
+ approved headers currently include "cache.h", "builtin.h",
+ "t/helper/test-tool.h", "xdiff/xinclude.h", or
+ "reftable/system.h"). You do not have to include more than one of
+ these.
- A C file must directly include the header files that declare the
functions and the types it uses, except for the functions and types
diff --git a/cbtree.c b/cbtree.c
index 336e46dbba..c1cc30a5dc 100644
--- a/cbtree.c
+++ b/cbtree.c
@@ -4,6 +4,7 @@
* Based on Adam Langley's adaptation of Dan Bernstein's public domain code
* git clone https://github.com/agl/critbit.git
*/
+#include "git-compat-util.h"
#include "cbtree.h"
static struct cb_node *cb_node_of(const void *p)
diff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c
index e08c505c14..c9536dfb66 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 6abbc7af3a..58b623fbb9 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/diff-merges.c b/diff-merges.c
index 85cbefa5af..faa7bc73a3 100644
--- a/diff-merges.c
+++ b/diff-merges.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "diff-merges.h"
#include "revision.h"
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index f48f44f9cd..f317f12990 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "config.h"
#include "refs.h"
#include "object-store.h"
diff --git a/oidtree.c b/oidtree.c
index 0d39389bee..7d57b7b19e 100644
--- a/oidtree.c
+++ b/oidtree.c
@@ -2,6 +2,7 @@
* A wrapper around cbtree which stores oids
* May be used to replace oid-array for prefix (abbreviation) matches
*/
+#include "git-compat-util.h"
#include "oidtree.h"
#include "alloc.h"
#include "hash.h"
diff --git a/oss-fuzz/fuzz-commit-graph.c b/oss-fuzz/fuzz-commit-graph.c
index 914026f5d8..2992079dd9 100644
--- a/oss-fuzz/fuzz-commit-graph.c
+++ b/oss-fuzz/fuzz-commit-graph.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "commit-graph.h"
#include "repository.h"
diff --git a/oss-fuzz/fuzz-pack-headers.c b/oss-fuzz/fuzz-pack-headers.c
index 99da1d0fd3..150c0f5fa2 100644
--- a/oss-fuzz/fuzz-pack-headers.c
+++ b/oss-fuzz/fuzz-pack-headers.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "packfile.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
diff --git a/oss-fuzz/fuzz-pack-idx.c b/oss-fuzz/fuzz-pack-idx.c
index 0c3d777aac..609a343ee3 100644
--- a/oss-fuzz/fuzz-pack-idx.c
+++ b/oss-fuzz/fuzz-pack-idx.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "object-store.h"
#include "packfile.h"
diff --git a/prune-packed.c b/prune-packed.c
index 261520b472..d2813f6a40 100644
--- a/prune-packed.c
+++ b/prune-packed.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "object-store.h"
#include "packfile.h"
#include "progress.h"
diff --git a/rebase.c b/rebase.c
index 6775cddb28..17a570f1ff 100644
--- a/rebase.c
+++ b/rebase.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "rebase.h"
#include "config.h"
#include "gettext.h"
diff --git a/refs/debug.c b/refs/debug.c
index eed8bc94b0..ff7766bc63 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -1,4 +1,4 @@
-
+#include "git-compat-util.h"
#include "refs-internal.h"
#include "trace.h"
diff --git a/sub-process.c b/sub-process.c
index 6d4232294d..1daf5a9752 100644
--- a/sub-process.c
+++ b/sub-process.c
@@ -1,6 +1,7 @@
/*
* Generic implementation of background process infrastructure.
*/
+#include "git-compat-util.h"
#include "sub-process.h"
#include "sigchain.h"
#include "pkt-line.h"