@@ -332,35 +332,31 @@ void fmt_output_commit(struct strbuf *filename,
332332 strbuf_release (& subject );
333333}
334334
335+ void fmt_output_email_subject (struct strbuf * sb , struct rev_info * opt )
336+ {
337+ if (opt -> total > 0 ) {
338+ strbuf_addf (sb , "Subject: [%s%s%0*d/%d] " ,
339+ opt -> subject_prefix ,
340+ * opt -> subject_prefix ? " " : "" ,
341+ digits_in_number (opt -> total ),
342+ opt -> nr , opt -> total );
343+ } else if (opt -> total == 0 && opt -> subject_prefix && * opt -> subject_prefix ) {
344+ strbuf_addf (sb , "Subject: [%s] " ,
345+ opt -> subject_prefix );
346+ } else {
347+ strbuf_addstr (sb , "Subject: " );
348+ }
349+ }
350+
335351void log_write_email_headers (struct rev_info * opt , struct commit * commit ,
336- const char * * subject_p ,
337352 const char * * extra_headers_p ,
338353 int * need_8bit_cte_p )
339354{
340- const char * subject = NULL ;
341355 const char * extra_headers = opt -> extra_headers ;
342356 const char * name = oid_to_hex (opt -> zero_commit ?
343357 & null_oid : & commit -> object .oid );
344358
345359 * need_8bit_cte_p = 0 ; /* unknown */
346- if (opt -> total > 0 ) {
347- static char buffer [64 ];
348- snprintf (buffer , sizeof (buffer ),
349- "Subject: [%s%s%0*d/%d] " ,
350- opt -> subject_prefix ,
351- * opt -> subject_prefix ? " " : "" ,
352- digits_in_number (opt -> total ),
353- opt -> nr , opt -> total );
354- subject = buffer ;
355- } else if (opt -> total == 0 && opt -> subject_prefix && * opt -> subject_prefix ) {
356- static char buffer [256 ];
357- snprintf (buffer , sizeof (buffer ),
358- "Subject: [%s] " ,
359- opt -> subject_prefix );
360- subject = buffer ;
361- } else {
362- subject = "Subject: " ;
363- }
364360
365361 fprintf (opt -> diffopt .file , "From %s Mon Sep 17 00:00:00 2001\n" , name );
366362 graph_show_oneline (opt -> graph );
@@ -417,7 +413,6 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
417413 opt -> diffopt .stat_sep = buffer ;
418414 strbuf_release (& filename );
419415 }
420- * subject_p = subject ;
421416 * extra_headers_p = extra_headers ;
422417}
423418
@@ -602,8 +597,10 @@ void show_log(struct rev_info *opt)
602597 */
603598
604599 if (cmit_fmt_is_mail (opt -> commit_format )) {
605- log_write_email_headers (opt , commit , & ctx . subject , & extra_headers ,
600+ log_write_email_headers (opt , commit , & extra_headers ,
606601 & ctx .need_8bit_cte );
602+ ctx .rev = opt ;
603+ ctx .print_email_subject = 1 ;
607604 } else if (opt -> commit_format != CMIT_FMT_USERFORMAT ) {
608605 fputs (diff_get_color_opt (& opt -> diffopt , DIFF_COMMIT ), opt -> diffopt .file );
609606 if (opt -> commit_format != CMIT_FMT_ONELINE )
0 commit comments