Subject: Re: [PATCH 0/5] Header includes cleanup

From: Junio C Hamano <[email-masked]>
Date: Tue, 31 Mar 2009 09:04:38 -0700

Christian Couder <[email-masked]> writes:

> I think it's a good thing that you started working on it even if in the end 
> we decide that we want these cleanup to be done otherwise. At least we will 
> hopefully have clarified our include header policy.

Before seeing a lot of patches to change #include all over the place, I'd
like to see a simple guiding principle described, not just a subjective "I
think this makes things better" but with "... because of X and Y and Z".

The document Documentation/CodingGuidelines describes the only policy that
exists currently: git-compat-util.h must be the first thing the compiler
sees.  The language should probably be stronger than what appears there:

 - The first #include in C files, except in platform specific
   compat/ implementations, should be git-compat-util.h or another
   well-known header file that includes it at the beginning, namely
   cache.h or builtin.h.

Even though http.h may include "cache.h" at the very beginning, I'd rather
not to see http-walker.c lose inclusion of "cache.h".  It will force us to
remember that http.h is Ok to include as the first file, and that won't
scale.

The reason git-compat-util.h must be the first is because inclusion of all
the system header files is supposed to happen there, and there are some
platforms that have broken system header dependencies we do not want
application writers to care about, and the compat-util header knows about
them.