@@ -114,6 +114,7 @@ static int config_commit_verbose = -1; /* unspecified */
114114static int no_post_rewrite , allow_empty_message , pathspec_file_nul ;
115115static char * untracked_files_arg , * force_date , * ignore_submodule_arg , * ignored_arg ;
116116static char * sign_commit , * pathspec_from_file ;
117+ static struct strvec trailer_args = STRVEC_INIT ;
117118
118119/*
119120 * The default commit message cleanup mode will remove the lines
@@ -132,6 +133,14 @@ static struct strbuf message = STRBUF_INIT;
132133
133134static enum wt_status_format status_format = STATUS_FORMAT_UNSPECIFIED ;
134135
136+ static int opt_pass_trailer (const struct option * opt , const char * arg , int unset )
137+ {
138+ BUG_ON_OPT_NEG (unset );
139+
140+ strvec_pushl (& trailer_args , "--trailer" , arg , NULL );
141+ return 0 ;
142+ }
143+
135144static int opt_parse_porcelain (const struct option * opt , const char * arg , int unset )
136145{
137146 enum wt_status_format * value = (enum wt_status_format * )opt -> value ;
@@ -994,6 +1003,18 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
9941003
9951004 fclose (s -> fp );
9961005
1006+ if (trailer_args .nr ) {
1007+ struct child_process run_trailer = CHILD_PROCESS_INIT ;
1008+
1009+ strvec_pushl (& run_trailer .args , "interpret-trailers" ,
1010+ "--in-place" , git_path_commit_editmsg (), NULL );
1011+ strvec_pushv (& run_trailer .args , trailer_args .v );
1012+ run_trailer .git_cmd = 1 ;
1013+ if (run_command (& run_trailer ))
1014+ die (_ ("unable to pass trailers to --trailers" ));
1015+ strvec_clear (& trailer_args );
1016+ }
1017+
9971018 /*
9981019 * Reject an attempt to record a non-merge empty commit without
9991020 * explicit --allow-empty. In the cherry-pick case, it may be
@@ -1596,6 +1617,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
15961617 OPT_STRING (0 , "fixup" , & fixup_message , N_ ("[(amend|reword):]commit" ), N_ ("use autosquash formatted message to fixup or amend/reword specified commit" )),
15971618 OPT_STRING (0 , "squash" , & squash_message , N_ ("commit" ), N_ ("use autosquash formatted message to squash specified commit" )),
15981619 OPT_BOOL (0 , "reset-author" , & renew_authorship , N_ ("the commit is authored by me now (used with -C/-c/--amend)" )),
1620+ OPT_CALLBACK_F (0 , "trailer" , NULL , N_ ("trailer" ), N_ ("add custom trailer(s)" ), PARSE_OPT_NONEG , opt_pass_trailer ),
15991621 OPT_BOOL ('s' , "signoff" , & signoff , N_ ("add a Signed-off-by trailer" )),
16001622 OPT_FILENAME ('t' , "template" , & template_file , N_ ("use specified template file" )),
16011623 OPT_BOOL ('e' , "edit" , & edit_flag , N_ ("force edit of commit" )),
0 commit comments