@@ -114,6 +114,7 @@ static int config_commit_verbose = -1; /* unspecified */
114
114
static int no_post_rewrite , allow_empty_message , pathspec_file_nul ;
115
115
static char * untracked_files_arg , * force_date , * ignore_submodule_arg , * ignored_arg ;
116
116
static char * sign_commit , * pathspec_from_file ;
117
+ static struct strvec trailer_args = STRVEC_INIT ;
117
118
118
119
/*
119
120
* The default commit message cleanup mode will remove the lines
@@ -132,6 +133,14 @@ static struct strbuf message = STRBUF_INIT;
132
133
133
134
static enum wt_status_format status_format = STATUS_FORMAT_UNSPECIFIED ;
134
135
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
+
135
144
static int opt_parse_porcelain (const struct option * opt , const char * arg , int unset )
136
145
{
137
146
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,
994
1003
995
1004
fclose (s -> fp );
996
1005
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
+
997
1018
/*
998
1019
* Reject an attempt to record a non-merge empty commit without
999
1020
* 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)
1596
1617
OPT_STRING (0 , "fixup" , & fixup_message , N_ ("[(amend|reword):]commit" ), N_ ("use autosquash formatted message to fixup or amend/reword specified commit" )),
1597
1618
OPT_STRING (0 , "squash" , & squash_message , N_ ("commit" ), N_ ("use autosquash formatted message to squash specified commit" )),
1598
1619
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 ),
1599
1621
OPT_BOOL ('s' , "signoff" , & signoff , N_ ("add a Signed-off-by trailer" )),
1600
1622
OPT_FILENAME ('t' , "template" , & template_file , N_ ("use specified template file" )),
1601
1623
OPT_BOOL ('e' , "edit" , & edit_flag , N_ ("force edit of commit" )),
0 commit comments