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

Re: [PATCH] help: ensure that common-cmds.h is only included by help.c

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 14, 2014, 05:23 UTC
Message-ID
<CAPc5daXDCAi3eP3YmXfcO+9ncN8=b6tCGUFUxwKE=MuRBuXvEg@mail.gmail.com>
In-Reply-To
<5414f6b2.XwoOyI03zlXiZ3ds%perryh@pluto.rain.com>
On Sat, Sep 13, 2014 at 7:00 PM, Perry Hutchison <perryh@pluto.rain.com> wrote:
Show 8 quoted lines
> David Aguilar <davvid@gmail.com> wrote:
>> Add a #ifndef guard to ensure that common-cmds.h can only
>> be included by help.c.
>
> This strikes me as a very peculiar, and sub-optimal, way of
> achieving the purpose.  If these definitions are intended to
> be private to help.c, why not put them there and eliminate
> common-cmds.h entirely?

Have you studied where common-cmds.h comes from? After you have done so, would you make the same suggestion?

Having said that, I also do not think this is such a good idea. Wouldn't the new "check" script added in this series a better place? For example, it may want to make sure that git-compat-util.h (or a couple of its equivalents) is the first file included in any mainline C source file, and such an inclusion is done unconditionally.

Which would mean that the checker would scan *.c files with grep or a Perl script. It would be trivial to enforce "nobody other than these small selected C files is allowed to include common-cmds.h" rule.

Regarding the other patch that butchers many *.h files, I am not still very enthused. Including cache.h at the beginning of branch.h, for example, would mean git-compat-util.h ends up included at the beginning of branch.h.

Previous: Perry HutchisonNext: David Aguilar
Message 3 of 6 in “help: ensure that common-cmds.h is only included by help.c”
  1. help: ensure that common-cmds.h is only included by help.cDavid Aguilar, Sep 14, 2014
  2. Perry HutchisonSep 14, 2014
  3. Junio C HamanoSep 14, 2014
  4. David AguilarSep 14, 2014
  5. Perry HutchisonSep 14, 2014
  6. David AguilarSep 14, 2014

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.