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
David Aguilar <davvid@gmail.com>
Date
Sep 14, 2014, 07:35 UTC
Message-ID
<20140914073511.GA39361@gmail.com>
In-Reply-To
<CAPc5daXDCAi3eP3YmXfcO+9ncN8=b6tCGUFUxwKE=MuRBuXvEg@mail.gmail.com>
On Sat, Sep 13, 2014 at 10:23:03PM -0700, Junio C Hamano wrote:
Show 22 quoted lines
> On Sat, Sep 13, 2014 at 7:00 PM, Perry Hutchison <perryh@pluto.rain.com> wrote:
> > 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.

Good idea. I implemented this check and the tweaks to make it pass are small and focused. I'll send these patches shortly.

> 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.

I can look into Jonathan's forward-decl approach later too. That'll probably result in less of a butchering.

-- 
David
Previous: Junio C HamanoNext: Perry Hutchison
Message 4 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.