mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
parse-options: add precision handling for OPTION_SET_INT
Similar to 09705696f7 (parse-options: introduce precision handling for
`OPTION_INTEGER`, 2025-04-17) support value variables of different sizes
for OPTION_SET_INT. Do that by requiring their "precision" to be set,
casting their "value" pointer accordingly and checking whether the value
fits.
Factor out the casting code from the part of do_get_value() that handles
OPTION_INTEGER to avoid code duplication. We're going to use it in the
next patches as well.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
0d3e045b34
commit
c898bbc5e4
@@ -190,6 +190,7 @@ struct option {
|
||||
.short_name = (s), \
|
||||
.long_name = (l), \
|
||||
.value = (v), \
|
||||
.precision = sizeof(*v), \
|
||||
.help = (h), \
|
||||
.flags = PARSE_OPT_NOARG | (f), \
|
||||
.defval = (i), \
|
||||
@@ -260,6 +261,7 @@ struct option {
|
||||
.short_name = (s), \
|
||||
.long_name = (l), \
|
||||
.value = (v), \
|
||||
.precision = sizeof(*v), \
|
||||
.help = (h), \
|
||||
.flags = PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, \
|
||||
.defval = 1, \
|
||||
|
||||
Reference in New Issue
Block a user