aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/fmt-merge-msg.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-04-24 17:25:33 -0700
committerJunio C Hamano <gitster@pobox.com>2025-04-24 17:25:34 -0700
commit2bc5414c411aab33c155b1070b7764ef6a49a02d (patch)
tree3f2b065f7c9c54838ab380ba5d16e7a9f742344b /builtin/fmt-merge-msg.c
parentMerge branch 'ds/doc-disable-hooks' (diff)
parentparse-options: detect mismatches in integer signedness (diff)
downloadgit-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/fmt-merge-msg.c')
-rw-r--r--builtin/fmt-merge-msg.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 189cd1096a..3b6aac2cf7 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -20,13 +20,26 @@ int cmd_fmt_merge_msg(int argc,
char *into_name = NULL;
int shortlog_len = -1;
struct option options[] = {
- { OPTION_INTEGER, 0, "log", &shortlog_len, N_("n"),
- N_("populate log with at most <n> entries from shortlog"),
- PARSE_OPT_OPTARG, NULL, DEFAULT_MERGE_LOG_LEN },
- { OPTION_INTEGER, 0, "summary", &shortlog_len, N_("n"),
- N_("alias for --log (deprecated)"),
- PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN, NULL,
- DEFAULT_MERGE_LOG_LEN },
+ {
+ .type = OPTION_INTEGER,
+ .long_name = "log",
+ .value = &shortlog_len,
+ .precision = sizeof(shortlog_len),
+ .argh = N_("n"),
+ .help = N_("populate log with at most <n> entries from shortlog"),
+ .flags = PARSE_OPT_OPTARG,
+ .defval = DEFAULT_MERGE_LOG_LEN,
+ },
+ {
+ .type = OPTION_INTEGER,
+ .long_name = "summary",
+ .value = &shortlog_len,
+ .precision = sizeof(shortlog_len),
+ .argh = N_("n"),
+ .help = N_("alias for --log (deprecated)"),
+ .flags = PARSE_OPT_OPTARG | PARSE_OPT_HIDDEN,
+ .defval = DEFAULT_MERGE_LOG_LEN,
+ },
OPT_STRING('m', "message", &message, N_("text"),
N_("use <text> as start of message")),
OPT_STRING(0, "into-name", &into_name, N_("name"),