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

Re: [PATCH v2 7/8] range-diff: passthrough --[no-]notes to `git log`

From
Denton Liu <liu.denton@gmail.com>
Date
Nov 21, 2019, 18:35 UTC
Message-ID
<20191121183539.GA99414@generichostname>
In-Reply-To
<CAPig+cQ0xO2ya=3ok=GPV2Ji2HJSFvCtokiRpWJhBAR1skqKVQ@mail.gmail.com>
Hi Eric,
On Thu, Nov 21, 2019 at 07:43:18AM -0500, Eric Sunshine wrote:
Show 30 quoted lines
> On Wed, Nov 20, 2019 at 2:13 PM Denton Liu <liu.denton@gmail.com> wrote:
> > On Wed, Nov 20, 2019 at 01:26:04PM +0900, Junio C Hamano wrote:
> > > Denton Liu <liu.denton@gmail.com> writes:
> > > > +#include "argv-array.h"
> > > >
> > > >  int show_range_diff(const char *range1, const char *range2,
> > > >                 int creation_factor, int dual_color,
> > > > -               struct diff_options *diffopt);
> > > > +               struct diff_options *diffopt,
> > > > +               struct argv_array *other_arg);
> > >
> > > I thought a mere use of "pointer to a struct" did not have to bring
> > > the definition of the struct into the picture?  In other words,
> > > wouldn't it be fine to leave the other_arg a pointer to an opaque
> > > structure by not including "argv-array.h" in this file?
> >
> > Without including "argv-array.h", we get the following hdr-check error:
> >
> >         $ make range-diff.hco
> >         In file included from range-diff.hcc:2:
> >         ./range-diff.h:16:14: error: declaration of 'struct argv_array' will not be visible outside of this function [-Werror,-Wvisibility]
> >                             struct argv_array *other_arg);
> 
> Did you forward-declare 'argv_array' in range-diff.h? That is, rather than:
> 
>     #include "argv-array.h"
> 
> instead say:
> 
>     struct argv_array;

*facepalm* Damn, sorry for the brainfart. I completely forgot to do that.

That being said, I'd prefer to just include the header for consistency since we already have the #include "diff.h" up there. Or alternatively, I could write a patch to change both into forward-declarations.

Personally, I prefer to avoid forward-declarations whenever possible because it adds duplication. If we have a strong preference for one or the other, should we include it in the CodingGuidelines?

Thanks,
Denton
Show 6 quoted lines
> 
> which tells the compiler that the type exists, thus allowing you to
> deal with pointers to the struct, as long as you don't try to access
> any of the struct's members in code which has seen only the forward
> declaration. You would still need to #include "argv-array.h" in
> range-diff.c, though.
Previous: Eric SunshineNext: Denton Liu
Message 20 of 32 in “range-diff: don't compare notes”
  1. 0/3 range-diff: don't compare notesDenton Liu, Nov 19, 2019
  2. 1/3 t3206: remove spaces after redirect operatorsDenton Liu, Nov 19, 2019
  3. 2/3 t3206: demonstrate failure with notesDenton Liu, Nov 19, 2019
  4. Junio C HamanoNov 19, 2019
  5. 3/3 range-diff: use --no-notes to generate patchesDenton Liu, Nov 19, 2019
  6. Junio C HamanoNov 19, 2019
  7. 0/8 range-diff: learn `--notes`Denton Liu, Nov 19, 2019
  8. 1/8 argv-array: add space after `while`Denton Liu, Nov 19, 2019
  9. 2/8 rev-list-options.txt: remove reference to --show-notesDenton Liu, Nov 19, 2019
  10. 3/8 t3206: remove spaces after redirect operatorsDenton Liu, Nov 19, 2019
  11. Eric SunshineNov 20, 2019
  12. 4/8 t3206: s/expected/expect/Denton Liu, Nov 19, 2019
  13. 5/8 t3206: demonstrate current notes behaviorDenton Liu, Nov 19, 2019
  14. Junio C HamanoNov 20, 2019
  15. 6/8 range-diff: output `## Notes ##` headerDenton Liu, Nov 19, 2019
  16. 7/8 range-diff: passthrough --[no-]notes to `git log`Denton Liu, Nov 19, 2019
  17. Junio C HamanoNov 20, 2019
  18. Denton LiuNov 20, 2019
  19. Eric SunshineNov 21, 2019
  20. Denton LiuNov 21, 2019
  21. 8/8 format-patch: pass notes configuration to range-diffDenton Liu, Nov 19, 2019
  22. 00/10 range-diff: learn `--notes`Denton Liu, Nov 20, 2019
  23. 01/10 argv-array: add space after `while`Denton Liu, Nov 20, 2019
  24. 02/10 rev-list-options.txt: remove reference to --show-notesDenton Liu, Nov 20, 2019
  25. 03/10 pretty-options.txt: --notes accepts a ref instead of treeishDenton Liu, Nov 20, 2019
  26. 04/10 t3206: remove spaces after redirect operatorsDenton Liu, Nov 20, 2019
  27. 05/10 t3206: disable parameter substitution in heredocDenton Liu, Nov 20, 2019
  28. 06/10 t3206: s/expected/expect/Denton Liu, Nov 20, 2019
  29. 07/10 t3206: range-diff compares logs with commit notesDenton Liu, Nov 20, 2019
  30. 08/10 range-diff: output `## Notes ##` headerDenton Liu, Nov 20, 2019
  31. 09/10 range-diff: pass through --notes to `git log`Denton Liu, Nov 20, 2019
  32. 10/10 format-patch: pass notes configuration to range-diffDenton Liu, Nov 20, 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.