Skip to content

Commit 56740f9

Browse files
jpassarogitster
authored andcommitted
builtin/commit: use ARGV macro to collect trailers
Replace git-commit's callback for --trailer with the standard OPT_PASSTHRU_ARGV macro. The callback only adds its values to a strvec and sanity-checks that `unset` is always false; both of these are already implemented in the parse-option API. Signed-off-by: John Passaro <[email protected]> Acked-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d4cc1ec commit 56740f9

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

builtin/commit.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,6 @@ static struct strbuf message = STRBUF_INIT;
142142

143143
static enum wt_status_format status_format = STATUS_FORMAT_UNSPECIFIED;
144144

145-
static int opt_pass_trailer(const struct option *opt, const char *arg, int unset)
146-
{
147-
BUG_ON_OPT_NEG(unset);
148-
149-
strvec_pushl(opt->value, "--trailer", arg, NULL);
150-
return 0;
151-
}
152-
153145
static int opt_parse_porcelain(const struct option *opt, const char *arg, int unset)
154146
{
155147
enum wt_status_format *value = (enum wt_status_format *)opt->value;
@@ -1673,7 +1665,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
16731665
OPT_STRING(0, "fixup", &fixup_message, N_("[(amend|reword):]commit"), N_("use autosquash formatted message to fixup or amend/reword specified commit")),
16741666
OPT_STRING(0, "squash", &squash_message, N_("commit"), N_("use autosquash formatted message to squash specified commit")),
16751667
OPT_BOOL(0, "reset-author", &renew_authorship, N_("the commit is authored by me now (used with -C/-c/--amend)")),
1676-
OPT_CALLBACK_F(0, "trailer", &trailer_args, N_("trailer"), N_("add custom trailer(s)"), PARSE_OPT_NONEG, opt_pass_trailer),
1668+
OPT_PASSTHRU_ARGV(0, "trailer", &trailer_args, N_("trailer"), N_("add custom trailer(s)"), PARSE_OPT_NONEG),
16771669
OPT_BOOL('s', "signoff", &signoff, N_("add a Signed-off-by trailer")),
16781670
OPT_FILENAME('t', "template", &template_file, N_("use specified template file")),
16791671
OPT_BOOL('e', "edit", &edit_flag, N_("force edit of commit")),

0 commit comments

Comments
 (0)