summaryrefslogtreecommitdiff
path: root/builtin/merge.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/merge.c
parent68e5342e191a2de216dbf712a6dbfa49282429c4 (diff)
parent791aeddfa2fdb9e830e24c50c97bb5e8bf3613e6 (diff)
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/merge.c')
-rw-r--r--builtin/merge.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 9efd585842..ce90e52fe4 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -249,9 +249,16 @@ static struct option builtin_merge_options[] = {
OPT_BOOL(0, "stat", &show_diffstat,
N_("show a diffstat at the end of the merge")),
OPT_BOOL(0, "summary", &show_diffstat, N_("(synonym to --stat)")),
- { OPTION_INTEGER, 0, "log", &shortlog_len, N_("n"),
- N_("add (at most <n>) entries from shortlog to merge commit message"),
- PARSE_OPT_OPTARG, NULL, DEFAULT_MERGE_LOG_LEN },
+ {
+ .type = OPTION_INTEGER,
+ .long_name = "log",
+ .value = &shortlog_len,
+ .precision = sizeof(shortlog_len),
+ .argh = N_("n"),
+ .help = N_("add (at most <n>) entries from shortlog to merge commit message"),
+ .flags = PARSE_OPT_OPTARG,
+ .defval = DEFAULT_MERGE_LOG_LEN,
+ },
OPT_BOOL(0, "squash", &squash,
N_("create a single commit instead of doing a merge")),
OPT_BOOL(0, "commit", &option_commit,
@@ -273,9 +280,16 @@ static struct option builtin_merge_options[] = {
OPT_CALLBACK('m', "message", &merge_msg, N_("message"),
N_("merge commit message (for a non-fast-forward merge)"),
option_parse_message),
- { OPTION_LOWLEVEL_CALLBACK, 'F', "file", &merge_msg, N_("path"),
- N_("read message from file"), PARSE_OPT_NONEG,
- NULL, 0, option_read_message },
+ {
+ .type = OPTION_LOWLEVEL_CALLBACK,
+ .short_name = 'F',
+ .long_name = "file",
+ .value = &merge_msg,
+ .argh = N_("path"),
+ .help = N_("read message from file"),
+ .flags = PARSE_OPT_NONEG,
+ .ll_callback = option_read_message,
+ },
OPT_STRING(0, "into-name", &into_name, N_("name"),
N_("use <name> instead of the real target")),
OPT__VERBOSITY(&verbosity),
@@ -288,8 +302,16 @@ static struct option builtin_merge_options[] = {
OPT_BOOL(0, "allow-unrelated-histories", &allow_unrelated_histories,
N_("allow merging unrelated histories")),
OPT_SET_INT(0, "progress", &show_progress, N_("force progress reporting"), 1),
- { OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key-id"),
- N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
+ {
+ .type = OPTION_STRING,
+ .short_name = 'S',
+ .long_name = "gpg-sign",
+ .value = &sign_commit,
+ .argh = N_("key-id"),
+ .help = N_("GPG sign commit"),
+ .flags = PARSE_OPT_OPTARG,
+ .defval = (intptr_t) "",
+ },
OPT_AUTOSTASH(&autostash),
OPT_BOOL(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")),
OPT_BOOL(0, "signoff", &signoff, N_("add a Signed-off-by trailer")),