@@ -232,8 +232,9 @@ static void record_person(int which, struct string_list *people,
232232{
233233 char * name_buf , * name , * name_end ;
234234 struct string_list_item * elem ;
235- const char * field = ( which == 'a' ) ? "\nauthor " : "\ncommitter " ;
235+ const char * field ;
236236
237+ field = (which == 'a' ) ? "\nauthor " : "\ncommitter " ;
237238 name = strstr (commit -> buffer , field );
238239 if (!name )
239240 return ;
@@ -323,7 +324,8 @@ static void add_people_info(struct strbuf *out,
323324static void shortlog (const char * name ,
324325 struct origin_data * origin_data ,
325326 struct commit * head ,
326- struct rev_info * rev , int limit ,
327+ struct rev_info * rev ,
328+ struct fmt_merge_msg_opts * opts ,
327329 struct strbuf * out )
328330{
329331 int i , count = 0 ;
@@ -335,6 +337,7 @@ static void shortlog(const char *name,
335337 int flags = UNINTERESTING | TREESAME | SEEN | SHOWN | ADDED ;
336338 struct strbuf sb = STRBUF_INIT ;
337339 const unsigned char * sha1 = origin_data -> sha1 ;
340+ int limit = opts -> shortlog_len ;
338341
339342 branch = deref_tag (parse_object (sha1 ), sha1_to_hex (sha1 ), 40 );
340343 if (!branch || branch -> type != OBJ_COMMIT )
@@ -351,13 +354,15 @@ static void shortlog(const char *name,
351354
352355 if (commit -> parents && commit -> parents -> next ) {
353356 /* 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 );
355359 continue ;
356360 }
357- if (!count )
361+ if (!count && opts -> credit_people )
358362 /* the 'tip' committer */
359363 record_person ('c' , & committers , commit );
360- record_person ('a' , & authors , commit );
364+ if (opts -> credit_people )
365+ record_person ('a' , & authors , commit );
361366 count ++ ;
362367 if (subjects .nr > limit )
363368 continue ;
@@ -372,7 +377,8 @@ static void shortlog(const char *name,
372377 string_list_append (& subjects , strbuf_detach (& sb , NULL ));
373378 }
374379
375- add_people_info (out , & authors , & committers );
380+ if (opts -> credit_people )
381+ add_people_info (out , & authors , & committers );
376382 if (count > limit )
377383 strbuf_addf (out , "\n* %s: (%d commits)\n" , name , count );
378384 else
@@ -635,7 +641,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
635641 for (i = 0 ; i < origins .nr ; i ++ )
636642 shortlog (origins .items [i ].string ,
637643 origins .items [i ].util ,
638- head , & rev , opts -> shortlog_len , out );
644+ head , & rev , opts , out );
639645 }
640646
641647 strbuf_complete_line (out );
@@ -690,6 +696,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
690696
691697 memset (& opts , 0 , sizeof (opts ));
692698 opts .add_title = !message ;
699+ opts .credit_people = 1 ;
693700 opts .shortlog_len = shortlog_len ;
694701
695702 ret = fmt_merge_msg (& input , & output , & opts );
0 commit comments