On Wed, Jan 18, 2017 at 10:25:59AM -0800, Junio C Hamano wrote:
quoted hunk ↗ jump to hunk
quoted
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