Skip to content

Commit

Permalink
treewide: remove unnecessary git-compat-util.h includes in headers
Browse files Browse the repository at this point in the history
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/[email protected]/
[2] https://lore.kernel.org/git/[email protected]/

Signed-off-by: Elijah Newren <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
newren authored and gitster committed Feb 24, 2023
1 parent 8bff5ca commit f332121
Show file tree
Hide file tree
Showing 11 changed files with 0 additions and 15 deletions.
2 changes: 0 additions & 2 deletions advice.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef ADVICE_H
#define ADVICE_H

#include "git-compat-util.h"

struct string_list;

/*
Expand Down
2 changes: 0 additions & 2 deletions cbtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 0 additions & 1 deletion chunk-format.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef CHUNK_FORMAT_H
#define CHUNK_FORMAT_H

#include "git-compat-util.h"
#include "hash.h"

struct hashfile;
Expand Down
1 change: 0 additions & 1 deletion commit-graph.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef COMMIT_GRAPH_H
#define COMMIT_GRAPH_H

#include "git-compat-util.h"
#include "object-store.h"
#include "oidset.h"

Expand Down
2 changes: 0 additions & 2 deletions commit-slab-impl.h
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
1 change: 0 additions & 1 deletion hash.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef HASH_H
#define HASH_H

#include "git-compat-util.h"
#include "repository.h"

#if defined(SHA1_APPLE)
Expand Down
2 changes: 0 additions & 2 deletions pack-mtimes.h
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 0 additions & 1 deletion pkt-line.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef PKTLINE_H
#define PKTLINE_H

#include "git-compat-util.h"
#include "strbuf.h"
#include "sideband.h"

Expand Down
1 change: 0 additions & 1 deletion repository.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef REPOSITORY_H
#define REPOSITORY_H

#include "git-compat-util.h"
#include "path.h"

struct config_set;
Expand Down
1 change: 0 additions & 1 deletion sub-process.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef SUBPROCESS_H
#define SUBPROCESS_H

#include "git-compat-util.h"
#include "hashmap.h"
#include "run-command.h"

Expand Down
1 change: 0 additions & 1 deletion trace.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef TRACE_H
#define TRACE_H

#include "git-compat-util.h"
#include "strbuf.h"

/**
Expand Down

0 comments on commit f332121

Please sign in to comment.