77#include "string-list.h"
88
99static const char * const fmt_merge_msg_usage [] = {
10- "git fmt-merge-msg [--log|--no-log] [--file <file>]" ,
10+ "git fmt-merge-msg [-m <message>] [- -log|--no-log] [--file <file>]" ,
1111 NULL
1212};
1313
@@ -319,11 +319,14 @@ int fmt_merge_msg_shortlog(struct strbuf *in, struct strbuf *out) {
319319int cmd_fmt_merge_msg (int argc , const char * * argv , const char * prefix )
320320{
321321 const char * inpath = NULL ;
322+ const char * message = NULL ;
322323 struct option options [] = {
323324 OPT_BOOLEAN (0 , "log" , & merge_summary , "populate log with the shortlog" ),
324325 { OPTION_BOOLEAN , 0 , "summary" , & merge_summary , NULL ,
325326 "alias for --log (deprecated)" ,
326327 PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
328+ OPT_STRING ('m' , "message" , & message , "text" ,
329+ "use <text> as start of message" ),
327330 OPT_FILENAME ('F' , "file" , & inpath , "file to read from" ),
328331 OPT_END ()
329332 };
@@ -337,6 +340,12 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
337340 0 );
338341 if (argc > 0 )
339342 usage_with_options (fmt_merge_msg_usage , options );
343+ if (message && !merge_summary ) {
344+ char nl = '\n' ;
345+ write_in_full (STDOUT_FILENO , message , strlen (message ));
346+ write_in_full (STDOUT_FILENO , & nl , 1 );
347+ return 0 ;
348+ }
340349
341350 if (inpath && strcmp (inpath , "-" )) {
342351 in = fopen (inpath , "r" );
@@ -346,7 +355,12 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
346355
347356 if (strbuf_read (& input , fileno (in ), 0 ) < 0 )
348357 die_errno ("could not read input file" );
349- ret = fmt_merge_msg (merge_summary , & input , & output );
358+ if (message ) {
359+ strbuf_addstr (& output , message );
360+ ret = fmt_merge_msg_shortlog (& input , & output );
361+ } else {
362+ ret = fmt_merge_msg (merge_summary , & input , & output );
363+ }
350364 if (ret )
351365 return ret ;
352366 write_in_full (STDOUT_FILENO , output .buf , output .len );
0 commit comments