@@ -406,7 +406,7 @@ static const char *show_ident_date(const struct ident_split *ident,
406406 return show_date (date , tz , mode );
407407}
408408
409- void pp_user_info (const struct pretty_print_context * pp ,
409+ void pp_user_info (struct pretty_print_context * pp ,
410410 const char * what , struct strbuf * sb ,
411411 const char * line , const char * encoding )
412412{
@@ -432,6 +432,23 @@ void pp_user_info(const struct pretty_print_context *pp,
432432 map_user (pp -> mailmap , & mailbuf , & maillen , & namebuf , & namelen );
433433
434434 if (pp -> fmt == CMIT_FMT_EMAIL ) {
435+ if (pp -> from_ident ) {
436+ struct strbuf buf = STRBUF_INIT ;
437+
438+ strbuf_addstr (& buf , "From: " );
439+ strbuf_add (& buf , namebuf , namelen );
440+ strbuf_addstr (& buf , " <" );
441+ strbuf_add (& buf , mailbuf , maillen );
442+ strbuf_addstr (& buf , ">\n" );
443+ string_list_append (& pp -> in_body_headers ,
444+ strbuf_detach (& buf , NULL ));
445+
446+ mailbuf = pp -> from_ident -> mail_begin ;
447+ maillen = pp -> from_ident -> mail_end - mailbuf ;
448+ namebuf = pp -> from_ident -> name_begin ;
449+ namelen = pp -> from_ident -> name_end - namebuf ;
450+ }
451+
435452 strbuf_addstr (sb , "From: " );
436453 if (needs_rfc2047_encoding (namebuf , namelen , RFC2047_ADDRESS )) {
437454 add_rfc2047 (sb , namebuf , namelen ,
@@ -1514,7 +1531,7 @@ void format_commit_message(const struct commit *commit,
15141531 free (context .signature_check .signer );
15151532}
15161533
1517- static void pp_header (const struct pretty_print_context * pp ,
1534+ static void pp_header (struct pretty_print_context * pp ,
15181535 const char * encoding ,
15191536 const struct commit * commit ,
15201537 const char * * msg_p ,
@@ -1575,7 +1592,7 @@ static void pp_header(const struct pretty_print_context *pp,
15751592 }
15761593}
15771594
1578- void pp_title_line (const struct pretty_print_context * pp ,
1595+ void pp_title_line (struct pretty_print_context * pp ,
15791596 const char * * msg_p ,
15801597 struct strbuf * sb ,
15811598 const char * encoding ,
@@ -1602,6 +1619,16 @@ void pp_title_line(const struct pretty_print_context *pp,
16021619 }
16031620 strbuf_addch (sb , '\n' );
16041621
1622+ if (need_8bit_cte == 0 ) {
1623+ int i ;
1624+ for (i = 0 ; i < pp -> in_body_headers .nr ; i ++ ) {
1625+ if (has_non_ascii (pp -> in_body_headers .items [i ].string )) {
1626+ need_8bit_cte = 1 ;
1627+ break ;
1628+ }
1629+ }
1630+ }
1631+
16051632 if (need_8bit_cte > 0 ) {
16061633 const char * header_fmt =
16071634 "MIME-Version: 1.0\n"
@@ -1615,10 +1642,21 @@ void pp_title_line(const struct pretty_print_context *pp,
16151642 if (pp -> fmt == CMIT_FMT_EMAIL ) {
16161643 strbuf_addch (sb , '\n' );
16171644 }
1645+
1646+ if (pp -> in_body_headers .nr ) {
1647+ int i ;
1648+ for (i = 0 ; i < pp -> in_body_headers .nr ; i ++ ) {
1649+ strbuf_addstr (sb , pp -> in_body_headers .items [i ].string );
1650+ free (pp -> in_body_headers .items [i ].string );
1651+ }
1652+ string_list_clear (& pp -> in_body_headers , 0 );
1653+ strbuf_addch (sb , '\n' );
1654+ }
1655+
16181656 strbuf_release (& title );
16191657}
16201658
1621- void pp_remainder (const struct pretty_print_context * pp ,
1659+ void pp_remainder (struct pretty_print_context * pp ,
16221660 const char * * msg_p ,
16231661 struct strbuf * sb ,
16241662 int indent )
@@ -1650,7 +1688,7 @@ void pp_remainder(const struct pretty_print_context *pp,
16501688 }
16511689}
16521690
1653- void pretty_print_commit (const struct pretty_print_context * pp ,
1691+ void pretty_print_commit (struct pretty_print_context * pp ,
16541692 const struct commit * commit ,
16551693 struct strbuf * sb )
16561694{
0 commit comments