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

Re: [PATCH v6 4/6] builtin/tag: add --format argument for tag -v

From
Jeff King <peff@peff.net>
Date
Jan 18, 2017, 18:28 UTC
Message-ID
<20170118182843.iyico5jpii6a3z7i@sigill.intra.peff.net>
In-Reply-To
<xmqqh94wb4y0.fsf@gitster.mtv.corp.google.com>
On Wed, Jan 18, 2017 at 10:25:59AM -0800, Junio C Hamano wrote:
Show 25 quoted lines
> > This triggers:
> >
> >     builtin/tag.c: In function 'cmd_tag':
> >     builtin/tag.c:451:3: error: passing argument 3 of
> >     'for_each_tag_name' discards 'const' qualifier from pointer target type [-Werror]
> >        return for_each_tag_name(argv, verify_tag, format);
> >
> > Either for-each-tag-name's new parameter needs to be typed
> > correctly, or the type of the "format" variable needs to be updated.
> 
> Squashing the following into this commit solves this issue with the
> former approach.  The lines it touches are all from 4/6 and I view
> all of it as general improvement, including type correctness and
> code formatting.
> 
> diff --git a/builtin/tag.c b/builtin/tag.c
> index f81273a85a..fbb85ba3dc 100644
> --- a/builtin/tag.c
> +++ b/builtin/tag.c
> @@ -66,10 +66,10 @@ static int list_tags(struct ref_filter *filter, struct ref_sorting *sorting, con
>  }
>  
>  typedef int (*each_tag_name_fn)(const char *name, const char *ref,
> -				const unsigned char *sha1, void *cb_data);
> +				const unsigned char *sha1, const void *cb_data);

This would bite us later if one of the iterators really does need to pass something mutable. But as this iteration interface is confined to builtin/tag.c, I think it's a nice simple fix.

A more general fix would be to pass a non-const pointer to const pointer (preferably inside a struct for readability). But I don't see any need for that complexity here.

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 20 in “Add --format to tag verification”
  1. 0/6 Add --format to tag verificationsantiago@nyu.edu, Jan 17, 2017
  2. 6/6 t/t7004-tag: Add --format specifier testssantiago@nyu.edu, Jan 17, 2017
  3. 3/6 builtin/verify-tag: add --format to verify-tagsantiago@nyu.edu, Jan 17, 2017
  4. 1/6 gpg-interface,tag: add GPG_VERIFY_OMIT_STATUS flagsantiago@nyu.edu, Jan 17, 2017
  5. 2/6 ref-filter: add function to print single ref_array_itemsantiago@nyu.edu, Jan 17, 2017
  6. 4/6 builtin/tag: add --format argument for tag -vsantiago@nyu.edu, Jan 17, 2017
  7. Junio C HamanoJan 18, 2017
  8. Junio C HamanoJan 18, 2017
  9. Junio C HamanoJan 18, 2017
  10. Junio C HamanoJan 18, 2017
  11. Jeff KingJan 18, 2017
  12. Junio C HamanoJan 18, 2017
  13. Santiago TorresJan 18, 2017
  14. Junio C HamanoJan 18, 2017
  15. Santiago TorresJan 18, 2017
  16. Eric WongJan 18, 2017
  17. Eric WongJan 19, 2017
  18. Junio C HamanoJan 18, 2017
  19. 5/6 t/t7030-verify-tag: Add --format specifier testssantiago@nyu.edu, Jan 17, 2017
  20. Junio C HamanoJan 18, 2017

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.