parse-options: add precision handling for OPTION_NEGBIT

Similar to 09705696f7 (parse-options: introduce precision handling for
`OPTION_INTEGER`, 2025-04-17) support value variables of different sizes
for OPTION_NEGBIT.  Do that by requiring their "precision" to be set,
casting their "value" pointer accordingly and checking whether the value
fits.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2025-07-09 11:45:53 +02:00
committed by Junio C Hamano
parent 5228211c4b
commit feeebbf1b7
3 changed files with 9 additions and 4 deletions

View File

@@ -250,6 +250,7 @@ struct option {
.short_name = (s), \
.long_name = (l), \
.value = (v), \
.precision = sizeof(*v), \
.help = (h), \
.flags = PARSE_OPT_NOARG, \
.defval = (b), \