Skip to content

Commit 8bff5ca

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 06dd2ba commit 8bff5ca

14 files changed

+19
-3
lines changed

Documentation/CodingGuidelines

+6-2
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,12 @@ For C programs:
442442
detail.
443443

444444
- The first #include in C files, except in platform specific compat/
445-
implementations, must be either "git-compat-util.h", "cache.h" or
446-
"builtin.h". You do not have to include more than one of these.
445+
implementations and sha1dc/, must be either "git-compat-util.h" or
446+
one of the approved headers that includes it first for you. (The
447+
approved headers currently include "cache.h", "builtin.h",
448+
"t/helper/test-tool.h", "xdiff/xinclude.h", or
449+
"reftable/system.h"). You do not have to include more than one of
450+
these.
447451

448452
- A C file must directly include the header files that declare the
449453
functions and the types it uses, except for the functions and types

cbtree.c

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Based on Adam Langley's adaptation of Dan Bernstein's public domain code
55
* git clone https://github.com/agl/critbit.git
66
*/
7+
#include "git-compat-util.h"
78
#include "cbtree.h"
89

910
static struct cb_node *cb_node_of(const void *p)

compat/fsmonitor/fsm-ipc-win32.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "git-compat-util.h"
12
#include "config.h"
23
#include "fsmonitor-ipc.h"
34

compat/fsmonitor/fsm-settings-darwin.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "git-compat-util.h"
12
#include "config.h"
23
#include "fsmonitor.h"
34
#include "fsmonitor-ipc.h"

diff-merges.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "git-compat-util.h"
12
#include "diff-merges.h"
23

34
#include "revision.h"

fmt-merge-msg.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "git-compat-util.h"
12
#include "config.h"
23
#include "refs.h"
34
#include "object-store.h"

oidtree.c

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* A wrapper around cbtree which stores oids
33
* May be used to replace oid-array for prefix (abbreviation) matches
44
*/
5+
#include "git-compat-util.h"
56
#include "oidtree.h"
67
#include "alloc.h"
78
#include "hash.h"

oss-fuzz/fuzz-commit-graph.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "git-compat-util.h"
12
#include "commit-graph.h"
23
#include "repository.h"
34

oss-fuzz/fuzz-pack-headers.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "git-compat-util.h"
12
#include "packfile.h"
23

34
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);

oss-fuzz/fuzz-pack-idx.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "git-compat-util.h"
12
#include "object-store.h"
23
#include "packfile.h"
34

prune-packed.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "git-compat-util.h"
12
#include "object-store.h"
23
#include "packfile.h"
34
#include "progress.h"

rebase.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "git-compat-util.h"
12
#include "rebase.h"
23
#include "config.h"
34
#include "gettext.h"

refs/debug.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
#include "git-compat-util.h"
22
#include "refs-internal.h"
33
#include "trace.h"
44

sub-process.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Generic implementation of background process infrastructure.
33
*/
4+
#include "git-compat-util.h"
45
#include "sub-process.h"
56
#include "sigchain.h"
67
#include "pkt-line.h"

0 commit comments

Comments
 (0)