@@ -209,7 +209,7 @@ static void shortlog(const char *name, unsigned char *sha1,
209
209
string_list_clear (& subjects , 0 );
210
210
}
211
211
212
- static void do_fmt_merge_msg_title (struct strbuf * out ,
212
+ static void fmt_merge_msg_title (struct strbuf * out ,
213
213
const char * current_branch ) {
214
214
int i = 0 ;
215
215
char * sep = "" ;
@@ -262,8 +262,9 @@ static void do_fmt_merge_msg_title(struct strbuf *out,
262
262
strbuf_addf (out , " into %s\n" , current_branch );
263
263
}
264
264
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
+ {
267
268
int i = 0 , pos = 0 ;
268
269
unsigned char head_sha1 [20 ];
269
270
const char * current_branch ;
@@ -289,10 +290,10 @@ static int do_fmt_merge_msg(int merge_title, struct strbuf *in,
289
290
die ("Error in line %d: %.*s" , i , len , p );
290
291
}
291
292
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 );
294
295
295
- if (shortlog_len ) {
296
+ if (opts -> shortlog_len ) {
296
297
struct commit * head ;
297
298
struct rev_info rev ;
298
299
@@ -307,18 +308,13 @@ static int do_fmt_merge_msg(int merge_title, struct strbuf *in,
307
308
308
309
for (i = 0 ; i < origins .nr ; i ++ )
309
310
shortlog (origins .items [i ].string , origins .items [i ].util ,
310
- head , & rev , shortlog_len , out );
311
+ head , & rev , opts -> shortlog_len , out );
311
312
}
312
313
if (out -> len && out -> buf [out -> len - 1 ] != '\n' )
313
314
strbuf_addch (out , '\n' );
314
315
return 0 ;
315
316
}
316
317
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
-
322
318
int cmd_fmt_merge_msg (int argc , const char * * argv , const char * prefix )
323
319
{
324
320
const char * inpath = NULL ;
@@ -340,6 +336,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
340
336
FILE * in = stdin ;
341
337
struct strbuf input = STRBUF_INIT , output = STRBUF_INIT ;
342
338
int ret ;
339
+ struct fmt_merge_msg_opts opts ;
343
340
344
341
git_config (fmt_merge_msg_config , NULL );
345
342
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)
361
358
362
359
if (message )
363
360
strbuf_addstr (& output , message );
364
- ret = fmt_merge_msg (& input , & output ,
365
- message ? 0 : 1 ,
366
- shortlog_len );
367
361
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 );
368
367
if (ret )
369
368
return ret ;
370
369
write_in_full (STDOUT_FILENO , output .buf , output .len );
0 commit comments