treewide: remove unnecessary git-compat-util.h includes in headers

For sanity, we should probably do one of the following:

(a) make C and header files both depend upon everything they need
(b) consistently exclude git-compat-util.h from headers and require it
    be the first include in C files

Currently, we have some of the headers following (a) and others
following (b), which makes things messy.  In the past I was pushed
towards (b), as per [1] and [2].  Further, during this series I
discovered that this mixture empirically will mean that we end up with C
files that do not directly include git-compat-util.h, and do include
headers that don't include git-compat-util.h, with the result that we
likely have headers included before an indirect inclusion of
git-compat-util.h.  Since git-compat-util.h has tricky platform-specific
stuff that is meant to be included before everything else, this state of
affairs is risky and may lead to things breaking in subtle ways (and
only on some platforms) as per [1] and [2].

Since including git-compat-util.h in existing header files makes it
harder for us to catch C files that are missing that include, let's
switch to (b) to make the enforcement of this rule easier.  Remove the
inclusion of git-compat-util.h from header files other than the ones
that have been approved as alternate first includes.

[1] https://lore.kernel.org/git/20180811173406.GA9119@sigill.intra.peff.net/
[2] https://lore.kernel.org/git/20180811174301.GA9287@sigill.intra.peff.net/

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren 2023-02-24 00:09:21 +00:00 committed by Junio C Hamano
parent 8bff5ca030
commit f332121e75
11 changed files with 0 additions and 15 deletions

View File

@ -1,8 +1,6 @@
#ifndef ADVICE_H #ifndef ADVICE_H
#define ADVICE_H #define ADVICE_H
#include "git-compat-util.h"
struct string_list; struct string_list;
/* /*

View File

@ -14,8 +14,6 @@
#ifndef CBTREE_H #ifndef CBTREE_H
#define CBTREE_H #define CBTREE_H
#include "git-compat-util.h"
struct cb_node; struct cb_node;
struct cb_node { struct cb_node {
struct cb_node *child[2]; struct cb_node *child[2];

View File

@ -1,7 +1,6 @@
#ifndef CHUNK_FORMAT_H #ifndef CHUNK_FORMAT_H
#define CHUNK_FORMAT_H #define CHUNK_FORMAT_H
#include "git-compat-util.h"
#include "hash.h" #include "hash.h"
struct hashfile; struct hashfile;

View File

@ -1,7 +1,6 @@
#ifndef COMMIT_GRAPH_H #ifndef COMMIT_GRAPH_H
#define COMMIT_GRAPH_H #define COMMIT_GRAPH_H
#include "git-compat-util.h"
#include "object-store.h" #include "object-store.h"
#include "oidset.h" #include "oidset.h"

View File

@ -1,8 +1,6 @@
#ifndef COMMIT_SLAB_IMPL_H #ifndef COMMIT_SLAB_IMPL_H
#define COMMIT_SLAB_IMPL_H #define COMMIT_SLAB_IMPL_H
#include "git-compat-util.h"
#define implement_static_commit_slab(slabname, elemtype) \ #define implement_static_commit_slab(slabname, elemtype) \
implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static) implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static)

1
hash.h
View File

@ -1,7 +1,6 @@
#ifndef HASH_H #ifndef HASH_H
#define HASH_H #define HASH_H
#include "git-compat-util.h"
#include "repository.h" #include "repository.h"
#if defined(SHA1_APPLE) #if defined(SHA1_APPLE)

View File

@ -1,8 +1,6 @@
#ifndef PACK_MTIMES_H #ifndef PACK_MTIMES_H
#define PACK_MTIMES_H #define PACK_MTIMES_H
#include "git-compat-util.h"
#define MTIMES_SIGNATURE 0x4d544d45 /* "MTME" */ #define MTIMES_SIGNATURE 0x4d544d45 /* "MTME" */
#define MTIMES_VERSION 1 #define MTIMES_VERSION 1

View File

@ -1,7 +1,6 @@
#ifndef PKTLINE_H #ifndef PKTLINE_H
#define PKTLINE_H #define PKTLINE_H
#include "git-compat-util.h"
#include "strbuf.h" #include "strbuf.h"
#include "sideband.h" #include "sideband.h"

View File

@ -1,7 +1,6 @@
#ifndef REPOSITORY_H #ifndef REPOSITORY_H
#define REPOSITORY_H #define REPOSITORY_H
#include "git-compat-util.h"
#include "path.h" #include "path.h"
struct config_set; struct config_set;

View File

@ -1,7 +1,6 @@
#ifndef SUBPROCESS_H #ifndef SUBPROCESS_H
#define SUBPROCESS_H #define SUBPROCESS_H
#include "git-compat-util.h"
#include "hashmap.h" #include "hashmap.h"
#include "run-command.h" #include "run-command.h"

View File

@ -1,7 +1,6 @@
#ifndef TRACE_H #ifndef TRACE_H
#define TRACE_H #define TRACE_H
#include "git-compat-util.h"
#include "strbuf.h" #include "strbuf.h"
/** /**