@@ -612,7 +612,6 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
612
612
int commitable , saved_color_setting ;
613
613
struct strbuf sb = STRBUF_INIT ;
614
614
char * buffer ;
615
- FILE * fp ;
616
615
const char * hook_arg1 = NULL ;
617
616
const char * hook_arg2 = NULL ;
618
617
int ident_shown = 0 ;
@@ -705,8 +704,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
705
704
hook_arg2 = "" ;
706
705
}
707
706
708
- fp = fopen (git_path (commit_editmsg ), "w" );
709
- if (fp == NULL )
707
+ s -> fp = fopen (git_path (commit_editmsg ), "w" );
708
+ if (s -> fp == NULL )
710
709
die_errno ("could not open '%s'" , git_path (commit_editmsg ));
711
710
712
711
if (cleanup_mode != CLEANUP_NONE )
@@ -730,7 +729,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
730
729
strbuf_release (& sob );
731
730
}
732
731
733
- if (fwrite (sb .buf , 1 , sb .len , fp ) < sb .len )
732
+ if (fwrite (sb .buf , 1 , sb .len , s -> fp ) < sb .len )
734
733
die_errno ("could not write commit template" );
735
734
736
735
strbuf_release (& sb );
@@ -743,56 +742,58 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
743
742
if (use_editor && include_status ) {
744
743
char * ai_tmp , * ci_tmp ;
745
744
if (whence != FROM_COMMIT )
746
- fprintf ( fp ,
747
- "# \n"
748
- "# It looks like you may be committing a %s.\n"
749
- "# If this is not correct, please remove the file\n"
750
- "# %s\n"
751
- "# and try again.\n"
752
- "#\n " ,
745
+ status_printf_ln ( s , GIT_COLOR_NORMAL ,
746
+ "\n"
747
+ "It looks like you may be committing a %s.\n"
748
+ "If this is not correct, please remove the file\n"
749
+ " %s\n"
750
+ "and try again.\n"
751
+ "" ,
753
752
whence_s (),
754
753
git_path (whence == FROM_MERGE
755
754
? "MERGE_HEAD"
756
755
: "CHERRY_PICK_HEAD" ));
757
- fprintf (fp ,
758
- "\n"
759
- "# Please enter the commit message for your changes." );
756
+
757
+ fprintf (s -> fp , "\n" );
758
+ status_printf (s , GIT_COLOR_NORMAL ,
759
+ "Please enter the commit message for your changes." );
760
760
if (cleanup_mode == CLEANUP_ALL )
761
- fprintf ( fp ,
761
+ status_printf_more ( s , GIT_COLOR_NORMAL ,
762
762
" Lines starting\n"
763
- "# with '#' will be ignored, and an empty"
763
+ "with '#' will be ignored, and an empty"
764
764
" message aborts the commit.\n" );
765
765
else /* CLEANUP_SPACE, that is. */
766
- fprintf ( fp ,
766
+ status_printf_more ( s , GIT_COLOR_NORMAL ,
767
767
" Lines starting\n"
768
- "# with '#' will be kept; you may remove them"
768
+ "with '#' will be kept; you may remove them"
769
769
" yourself if you want to.\n"
770
- "# An empty message aborts the commit.\n" );
770
+ "An empty message aborts the commit.\n" );
771
771
if (only_include_assumed )
772
- fprintf (fp , "# %s\n" , only_include_assumed );
772
+ status_printf_ln (s , GIT_COLOR_NORMAL ,
773
+ "%s" , only_include_assumed );
773
774
774
775
ai_tmp = cut_ident_timestamp_part (author_ident -> buf );
775
776
ci_tmp = cut_ident_timestamp_part (committer_ident .buf );
776
777
if (strcmp (author_ident -> buf , committer_ident .buf ))
777
- fprintf ( fp ,
778
+ status_printf_ln ( s , GIT_COLOR_NORMAL ,
778
779
"%s"
779
- "# Author: %s\n " ,
780
- ident_shown ++ ? "" : "# \n" ,
780
+ "Author: %s" ,
781
+ ident_shown ++ ? "" : "\n" ,
781
782
author_ident -> buf );
782
783
783
784
if (!user_ident_sufficiently_given ())
784
- fprintf ( fp ,
785
+ status_printf_ln ( s , GIT_COLOR_NORMAL ,
785
786
"%s"
786
- "# Committer: %s\n " ,
787
- ident_shown ++ ? "" : "# \n" ,
787
+ "Committer: %s" ,
788
+ ident_shown ++ ? "" : "\n" ,
788
789
committer_ident .buf );
789
790
790
791
if (ident_shown )
791
- fprintf ( fp , "#\n " );
792
+ status_printf_ln ( s , GIT_COLOR_NORMAL , " " );
792
793
793
794
saved_color_setting = s -> use_color ;
794
795
s -> use_color = 0 ;
795
- commitable = run_status (fp , index_file , prefix , 1 , s );
796
+ commitable = run_status (s -> fp , index_file , prefix , 1 , s );
796
797
s -> use_color = saved_color_setting ;
797
798
798
799
* ai_tmp = ' ' ;
@@ -814,7 +815,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
814
815
}
815
816
strbuf_release (& committer_ident );
816
817
817
- fclose (fp );
818
+ fclose (s -> fp );
818
819
819
820
/*
820
821
* Reject an attempt to record a non-merge empty commit without
0 commit comments