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

From: Junio C Hamano <[email-masked]>
Date: Thu, 23 Feb 2023 11:35:40 -0800

"Elijah Newren via GitGitGadget" <[email-masked]> writes:

> From: Elijah Newren <[email-masked]>
>
> 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.

Hmph, doesn't this cut both ways?  

I like the idea that the removal of compat-util from other
header files may increase the likelihood that a C file that includes
such header files without including compat-util fail to compile,
because it would fail to find what is defined or declared in
compat-util.

But from "include what you use" point of view, shouldn't a header
that defines or declares its own stuff using what is defined or
declared in compat-util be including compat-util itself?

Or do I misunderstand what "make hdr-check" is trying to achieve?

Granted that the check does not fail with this patch in place, but I
suspect that it is by accident (i.e. there happens to be nobody who
depends on what is defined/declared in compat-util for their own
definition or declaration).  Also I am not sure how to interpret
the fact that "make hdr-check" succeeds with this patch.  Does it
mean C files that include these header files while forgetting to
include compat-util may not be caught by the compiler after all?

So, I dunno.