Re: [PATCH] wt-status: move #include "pathspec.h" to the header
- From
Jeff King <peff@peff.net>
- Date
- Aug 20, 2015, 20:38 UTC
- Message-ID
- <20150820203841.GA12386@sigill.intra.peff.net>
- In-Reply-To
- <xmqq61497pc1.fsf@gitster.dls.corp.google.com>
On Thu, Aug 20, 2015 at 12:05:34PM -0700, Junio C Hamano wrote:
Show 18 quoted lines
> This is a tangent, but the above is different from saying that with > a single liner test.c that has > > #include "wt-status.h" > > your compilation "cc -c test.c" should succeed. But for that goal, > direct inclusion of <stdio.h> to wt-status.h is also iffy. We > include the system headers from git-compat-util.h because some > platforms are picky about order of inclusion of system header files > and definitions of feature test macros. > > Right now, the codebase is correct only because it is NOT our goal > to guarantee that such a single-liner test.c file compiles. > Instead, everybody is instructed to #include "git-compat-util.h" as > the first thing, either directly or indirectly. > > So in that sense, we should also remove that inclusion from > wt-status.h, I think.
Yeah, I think that is actively wrong. Running[1]:
git grep '#include <' -- '*.h' ':!git-compat-util.h'
shows a few other weird ones. Things like zlib.h, pcre.h, etc, are probably OK. They are not really "system" headers, and it is probably OK as long as they come after git-compat-util (which they must, if they are in a header file).
The inclusion of stdlib.h in compat/bswap.h is suspect (both are included by git-compat-util itself). But it is inside an #ifdef _MSC_VER block, so I cannot test that there is not some subtle interaction going on.
A few headers include pthread.h. I would have thought that should go in git-compat-util for the usual reasons, but nobody has complained (and most files do not need it, though that has not generally stopped us from making git-compat-util a catch-all for other system files).
-Peff
[1] Too bad I needed the "--" separator there. Recent git nicely learned
to DWIM "*.h" as a pathspec, but we do not seem to give the same
treatment to "magic" pathspecs.