@@ -232,8 +232,9 @@ static void record_person(int which, struct string_list *people,
232
232
{
233
233
char * name_buf , * name , * name_end ;
234
234
struct string_list_item * elem ;
235
- const char * field = ( which == 'a' ) ? "\nauthor " : "\ncommitter " ;
235
+ const char * field ;
236
236
237
+ field = (which == 'a' ) ? "\nauthor " : "\ncommitter " ;
237
238
name = strstr (commit -> buffer , field );
238
239
if (!name )
239
240
return ;
@@ -323,7 +324,8 @@ static void add_people_info(struct strbuf *out,
323
324
static void shortlog (const char * name ,
324
325
struct origin_data * origin_data ,
325
326
struct commit * head ,
326
- struct rev_info * rev , int limit ,
327
+ struct rev_info * rev ,
328
+ struct fmt_merge_msg_opts * opts ,
327
329
struct strbuf * out )
328
330
{
329
331
int i , count = 0 ;
@@ -335,6 +337,7 @@ static void shortlog(const char *name,
335
337
int flags = UNINTERESTING | TREESAME | SEEN | SHOWN | ADDED ;
336
338
struct strbuf sb = STRBUF_INIT ;
337
339
const unsigned char * sha1 = origin_data -> sha1 ;
340
+ int limit = opts -> shortlog_len ;
338
341
339
342
branch = deref_tag (parse_object (sha1 ), sha1_to_hex (sha1 ), 40 );
340
343
if (!branch || branch -> type != OBJ_COMMIT )
@@ -351,13 +354,15 @@ static void shortlog(const char *name,
351
354
352
355
if (commit -> parents && commit -> parents -> next ) {
353
356
/* do not list a merge but count committer */
354
- record_person ('c' , & committers , commit );
357
+ if (opts -> credit_people )
358
+ record_person ('c' , & committers , commit );
355
359
continue ;
356
360
}
357
- if (!count )
361
+ if (!count && opts -> credit_people )
358
362
/* the 'tip' committer */
359
363
record_person ('c' , & committers , commit );
360
- record_person ('a' , & authors , commit );
364
+ if (opts -> credit_people )
365
+ record_person ('a' , & authors , commit );
361
366
count ++ ;
362
367
if (subjects .nr > limit )
363
368
continue ;
@@ -372,7 +377,8 @@ static void shortlog(const char *name,
372
377
string_list_append (& subjects , strbuf_detach (& sb , NULL ));
373
378
}
374
379
375
- add_people_info (out , & authors , & committers );
380
+ if (opts -> credit_people )
381
+ add_people_info (out , & authors , & committers );
376
382
if (count > limit )
377
383
strbuf_addf (out , "\n* %s: (%d commits)\n" , name , count );
378
384
else
@@ -635,7 +641,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
635
641
for (i = 0 ; i < origins .nr ; i ++ )
636
642
shortlog (origins .items [i ].string ,
637
643
origins .items [i ].util ,
638
- head , & rev , opts -> shortlog_len , out );
644
+ head , & rev , opts , out );
639
645
}
640
646
641
647
strbuf_complete_line (out );
@@ -690,6 +696,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
690
696
691
697
memset (& opts , 0 , sizeof (opts ));
692
698
opts .add_title = !message ;
699
+ opts .credit_people = 1 ;
693
700
opts .shortlog_len = shortlog_len ;
694
701
695
702
ret = fmt_merge_msg (& input , & output , & opts );
0 commit comments