diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-04-24 17:25:33 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-04-24 17:25:34 -0700 |
| commit | 2bc5414c411aab33c155b1070b7764ef6a49a02d (patch) | |
| tree | 3f2b065f7c9c54838ab380ba5d16e7a9f742344b /builtin/tag.c | |
| parent | Merge branch 'ds/doc-disable-hooks' (diff) | |
| parent | parse-options: detect mismatches in integer signedness (diff) | |
| download | git-2bc5414c411aab33c155b1070b7764ef6a49a02d.tar.gz git-2bc5414c411aab33c155b1070b7764ef6a49a02d.zip | |
Merge branch 'ps/parse-options-integers'
Update parse-options API to catch mistakes to pass address of an
integral variable of a wrong type/size.
* ps/parse-options-integers:
parse-options: detect mismatches in integer signedness
parse-options: introduce precision handling for `OPTION_UNSIGNED`
parse-options: introduce precision handling for `OPTION_INTEGER`
parse-options: rename `OPT_MAGNITUDE()` to `OPT_UNSIGNED()`
parse-options: support unit factors in `OPT_INTEGER()`
global: use designated initializers for options
parse: fix off-by-one for minimum signed values
Diffstat (limited to 'builtin/tag.c')
| -rw-r--r-- | builtin/tag.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/builtin/tag.c b/builtin/tag.c index e6b372cebf..4742b27d16 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -480,9 +480,16 @@ int cmd_tag(int argc, int edit_flag = 0; struct option options[] = { OPT_CMDMODE('l', "list", &cmdmode, N_("list tag names"), 'l'), - { OPTION_INTEGER, 'n', NULL, &filter.lines, N_("n"), - N_("print <n> lines of each tag message"), - PARSE_OPT_OPTARG, NULL, 1 }, + { + .type = OPTION_INTEGER, + .short_name = 'n', + .value = &filter.lines, + .precision = sizeof(filter.lines), + .argh = N_("n"), + .help = N_("print <n> lines of each tag message"), + .flags = PARSE_OPT_OPTARG, + .defval = 1, + }, OPT_CMDMODE('d', "delete", &cmdmode, N_("delete tags"), 'd'), OPT_CMDMODE('v', "verify", &cmdmode, N_("verify tags"), 'v'), @@ -514,9 +521,14 @@ int cmd_tag(int argc, N_("do not output a newline after empty formatted refs")), OPT_REF_SORT(&sorting_options), { - OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"), - N_("print only tags of the object"), PARSE_OPT_LASTARG_DEFAULT, - parse_opt_object_name, (intptr_t) "HEAD" + .type = OPTION_CALLBACK, + .long_name = "points-at", + .value = &filter.points_at, + .argh = N_("object"), + .help = N_("print only tags of the object"), + .flags = PARSE_OPT_LASTARG_DEFAULT, + .callback = parse_opt_object_name, + .defval = (intptr_t) "HEAD", }, OPT_STRING( 0 , "format", &format.format, N_("format"), N_("format to use for the output")), |
