@@ -47,6 +47,7 @@ static enum {
4747
4848static char * logfile , * force_author , * template_file ;
4949static char * edit_message , * use_message ;
50+ static char * author_name , * author_email , * author_date ;
5051static int all , edit_flag , also , interactive , only , amend , signoff ;
5152static int quiet , verbose , untracked_files , no_verify , allow_empty ;
5253/*
@@ -395,7 +396,7 @@ static int is_a_merge(const unsigned char *sha1)
395396
396397static const char sign_off_header [] = "Signed-off-by: " ;
397398
398- static void determine_author_info (struct strbuf * sb )
399+ static void determine_author_info (void )
399400{
400401 char * name , * email , * date ;
401402
@@ -431,7 +432,9 @@ static void determine_author_info(struct strbuf *sb)
431432 email = xstrndup (lb + 2 , rb - (lb + 2 ));
432433 }
433434
434- strbuf_addf (sb , "author %s\n" , fmt_ident (name , email , date , IDENT_ERROR_ON_NO_NAME ));
435+ author_name = name ;
436+ author_email = email ;
437+ author_date = date ;
435438}
436439
437440static int prepare_to_commit (const char * index_file , const char * prefix )
@@ -522,7 +525,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
522525
523526 strbuf_release (& sb );
524527
528+ determine_author_info ();
529+
525530 if (use_editor ) {
531+ char * author_ident ;
532+ const char * committer_ident ;
533+
526534 if (in_merge )
527535 fprintf (fp ,
528536 "#\n"
@@ -545,6 +553,17 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
545553 if (only_include_assumed )
546554 fprintf (fp , "# %s\n" , only_include_assumed );
547555
556+ author_ident = xstrdup (fmt_name (author_name , author_email ));
557+ committer_ident = fmt_name (getenv ("GIT_COMMITTER_NAME" ),
558+ getenv ("GIT_COMMITTER_EMAIL" ));
559+ if (strcmp (author_ident , committer_ident ))
560+ fprintf (fp ,
561+ "#\n"
562+ "# Author: %s\n"
563+ "#\n" ,
564+ author_ident );
565+ free (author_ident );
566+
548567 saved_color_setting = wt_status_use_color ;
549568 wt_status_use_color = 0 ;
550569 commitable = run_status (fp , index_file , prefix , 1 );
@@ -920,7 +939,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
920939 strbuf_addf (& sb , "parent %s\n" , sha1_to_hex (head_sha1 ));
921940 }
922941
923- determine_author_info (& sb );
942+ strbuf_addf (& sb , "author %s\n" ,
943+ fmt_ident (author_name , author_email , author_date , IDENT_ERROR_ON_NO_NAME ));
924944 strbuf_addf (& sb , "committer %s\n" , git_committer_info (IDENT_ERROR_ON_NO_NAME ));
925945 if (!is_encoding_utf8 (git_commit_encoding ))
926946 strbuf_addf (& sb , "encoding %s\n" , git_commit_encoding );
0 commit comments