git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Junio C HamanoNext: SZEDER Gábor
Message 3 of 4 in “wt-status: move #include "pathspec.h" to the header”
  1. wt-status: move #include "pathspec.h" to the headerSZEDER Gábor, Aug 20, 2015
  2. Junio C HamanoAug 20, 2015
  3. Jeff KingAug 20, 2015
  4. SZEDER GáborAug 20, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.