@@ -209,7 +209,7 @@ static void shortlog(const char *name, unsigned char *sha1,
209209 string_list_clear (& subjects , 0 );
210210}
211211
212- static void do_fmt_merge_msg_title (struct strbuf * out ,
212+ static void fmt_merge_msg_title (struct strbuf * out ,
213213 const char * current_branch ) {
214214 int i = 0 ;
215215 char * sep = "" ;
@@ -262,8 +262,9 @@ static void do_fmt_merge_msg_title(struct strbuf *out,
262262 strbuf_addf (out , " into %s\n" , current_branch );
263263}
264264
265- static int do_fmt_merge_msg (int merge_title , struct strbuf * in ,
266- struct strbuf * out , int shortlog_len ) {
265+ int fmt_merge_msg (struct strbuf * in , struct strbuf * out ,
266+ struct fmt_merge_msg_opts * opts )
267+ {
267268 int i = 0 , pos = 0 ;
268269 unsigned char head_sha1 [20 ];
269270 const char * current_branch ;
@@ -289,10 +290,10 @@ static int do_fmt_merge_msg(int merge_title, struct strbuf *in,
289290 die ("Error in line %d: %.*s" , i , len , p );
290291 }
291292
292- if (merge_title && srcs .nr )
293- do_fmt_merge_msg_title (out , current_branch );
293+ if (opts -> add_title && srcs .nr )
294+ fmt_merge_msg_title (out , current_branch );
294295
295- if (shortlog_len ) {
296+ if (opts -> shortlog_len ) {
296297 struct commit * head ;
297298 struct rev_info rev ;
298299
@@ -307,18 +308,13 @@ static int do_fmt_merge_msg(int merge_title, struct strbuf *in,
307308
308309 for (i = 0 ; i < origins .nr ; i ++ )
309310 shortlog (origins .items [i ].string , origins .items [i ].util ,
310- head , & rev , shortlog_len , out );
311+ head , & rev , opts -> shortlog_len , out );
311312 }
312313 if (out -> len && out -> buf [out -> len - 1 ] != '\n' )
313314 strbuf_addch (out , '\n' );
314315 return 0 ;
315316}
316317
317- int fmt_merge_msg (struct strbuf * in , struct strbuf * out ,
318- int merge_title , int shortlog_len ) {
319- return do_fmt_merge_msg (merge_title , in , out , shortlog_len );
320- }
321-
322318int cmd_fmt_merge_msg (int argc , const char * * argv , const char * prefix )
323319{
324320 const char * inpath = NULL ;
@@ -340,6 +336,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
340336 FILE * in = stdin ;
341337 struct strbuf input = STRBUF_INIT , output = STRBUF_INIT ;
342338 int ret ;
339+ struct fmt_merge_msg_opts opts ;
343340
344341 git_config (fmt_merge_msg_config , NULL );
345342 argc = parse_options (argc , argv , prefix , options , fmt_merge_msg_usage ,
@@ -361,10 +358,12 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
361358
362359 if (message )
363360 strbuf_addstr (& output , message );
364- ret = fmt_merge_msg (& input , & output ,
365- message ? 0 : 1 ,
366- shortlog_len );
367361
362+ memset (& opts , 0 , sizeof (opts ));
363+ opts .add_title = !message ;
364+ opts .shortlog_len = shortlog_len ;
365+
366+ ret = fmt_merge_msg (& input , & output , & opts );
368367 if (ret )
369368 return ret ;
370369 write_in_full (STDOUT_FILENO , output .buf , output .len );
0 commit comments