From: Li Chen Date: Tue, 14 Oct 2025 12:24:16 GMT Subject: [PATCH v4 03/29] trailer: drop --trailer prefix handling in amend helper Message-ID: <20251014122452.1851103-4-me@linux.beauty> In-Reply-To: <20251014122452.1851103-1-me@linux.beauty> Make callers pass plain trailer text instead of recreating the option prefix before invoking interpret-trailers. Signed-off-by: Li Chen --- builtin/commit.c | 2 +- builtin/tag.c | 3 +-- trailer.c | 5 +---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 0243f17d53..67070d6a54 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1719,7 +1719,7 @@ int cmd_commit(int argc, OPT_STRING(0, "fixup", &fixup_message, N_("[(amend|reword):]commit"), N_("use autosquash formatted message to fixup or amend/reword specified commit")), OPT_STRING(0, "squash", &squash_message, N_("commit"), N_("use autosquash formatted message to squash specified commit")), OPT_BOOL(0, "reset-author", &renew_authorship, N_("the commit is authored by me now (used with -C/-c/--amend)")), - OPT_PASSTHRU_ARGV(0, "trailer", &trailer_args, N_("trailer"), N_("add custom trailer(s)"), PARSE_OPT_NONEG), + OPT_CALLBACK_F(0, "trailer", &trailer_args, N_("trailer"), N_("add custom trailer(s)"), PARSE_OPT_NONEG, parse_opt_strvec), OPT_BOOL('s', "signoff", &signoff, N_("add a Signed-off-by trailer")), OPT_FILENAME('t', "template", &template_file, N_("use specified template file")), OPT_BOOL('e', "edit", &edit_flag, N_("force edit of commit")), diff --git a/builtin/tag.c b/builtin/tag.c index f0665af3ac..65c4a0b36b 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -499,8 +499,7 @@ int cmd_tag(int argc, OPT_CALLBACK_F('m', "message", &msg, N_("message"), N_("tag message"), PARSE_OPT_NONEG, parse_msg_arg), OPT_FILENAME('F', "file", &msgfile, N_("read message from file")), - OPT_PASSTHRU_ARGV(0, "trailer", &trailer_args, N_("trailer"), - N_("add custom trailer(s)"), PARSE_OPT_NONEG), + OPT_CALLBACK_F(0, "trailer", &trailer_args, N_("trailer"), N_("add custom trailer(s)"), PARSE_OPT_NONEG, parse_opt_strvec), OPT_BOOL('e', "edit", &edit_flag, N_("force edit of tag message")), OPT_BOOL('s', "sign", &opt.sign, N_("annotated and GPG-signed tag")), OPT_CLEANUP(&cleanup_arg), diff --git a/trailer.c b/trailer.c index 8aec466b5f..42ac6f58a2 100644 --- a/trailer.c +++ b/trailer.c @@ -1235,12 +1235,9 @@ static int amend_strbuf_with_trailers(struct strbuf *buf, opts.no_divider = 1; for (i = 0; i < trailer_args->nr; i++) { - const char *arg = trailer_args->v[i]; - const char *text; + const char *text = trailer_args->v[i]; struct new_trailer_item *item; - if (!skip_prefix(arg, "--trailer=", &text)) - text = arg; if (!*text) continue; item = xcalloc(1, sizeof(*item)); -- 2.51.0