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

Re: PATCH] remove duplicate #include directives

From
René Scharfe <l.s.r@web.de>
Date
Oct 6, 2019, 10:16 UTC
Message-ID
<5af3ad29-5127-b5f7-46c9-f1d3d45b4e67@web.de>
In-Reply-To
<xmqqv9t269qk.fsf@gitster-ct.c.googlers.com>
Am 06.10.19 um 01:41 schrieb Junio C Hamano:
Show 13 quoted lines
> René Scharfe <l.s.r@web.de> writes:
>> This one here requires one more piece of information, though, namely our
>> convention of wrapping header files in guard defines to make repeated
>> includes of them no-ops.  We do that for those removed by the patch, but
>> we have a few exceptions to that rule in our repo (at least
>> command-list.h, kwset.h, sha1dc_git.h, tar.h, unicode-width.h).  So in
>> that sense it's not such a good example of a self-sufficient patch. :)
>
> Not really.  "We use header guards" is an argument that demotes this
> cleanup from "must have" to "nice to have".  If a project did not
> use header guards or including the same header twice were an error,
> the patch in question would have been more necessary, but that
> wouldn't have changed the correctness of the patch, I think.

You start with "No", but make my point -- a reader would need more information than the content of the patch itself to classify it as a trivial cleanup, namely knowledge of our use of include guards.

Here is an example of a non-idempotent header:
   #define NDEBUG
   ...
   #include <assert.h>
   ...
   #undef NDEBUG
   ...
   #include <assert.h>
(That's the only one we use that I'm aware of.)
René
Previous: Junio C Hamano
Message 5 of 5 in “PATCH] remove duplicate #include directives”
  1. René ScharfeOct 3, 2019
  2. Junio C HamanoOct 3, 2019
  3. René ScharfeOct 5, 2019
  4. Junio C HamanoOct 5, 2019
  5. René ScharfeOct 6, 2019

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.