@@ -643,27 +643,25 @@ static int is_scissors_line(const struct strbuf *line)
643
643
gap * 2 < perforation );
644
644
}
645
645
646
- static int handle_commit_msg (struct strbuf * line )
646
+ static int handle_commit_msg (struct strbuf * line , int * still_looking )
647
647
{
648
- static int still_looking = 1 ;
649
-
650
648
if (!cmitmsg )
651
649
return 0 ;
652
650
653
- if (still_looking ) {
651
+ if (* still_looking ) {
654
652
if (!line -> len || (line -> len == 1 && line -> buf [0 ] == '\n' ))
655
653
return 0 ;
656
654
}
657
655
658
- if (use_inbody_headers && still_looking ) {
659
- still_looking = check_header (line , s_hdr_data , 0 );
660
- if (still_looking )
656
+ if (use_inbody_headers && * still_looking ) {
657
+ * still_looking = check_header (line , s_hdr_data , 0 );
658
+ if (* still_looking )
661
659
return 0 ;
662
660
} else
663
661
/* Only trim the first (blank) line of the commit message
664
662
* when ignoring in-body headers.
665
663
*/
666
- still_looking = 0 ;
664
+ * still_looking = 0 ;
667
665
668
666
/* normalize the log message to UTF-8. */
669
667
if (metainfo_charset )
@@ -675,7 +673,7 @@ static int handle_commit_msg(struct strbuf *line)
675
673
die_errno ("Could not rewind output message file" );
676
674
if (ftruncate (fileno (cmitmsg ), 0 ))
677
675
die_errno ("Could not truncate output message file at scissors" );
678
- still_looking = 1 ;
676
+ * still_looking = 1 ;
679
677
680
678
/*
681
679
* We may have already read "secondary headers"; purge
@@ -707,16 +705,13 @@ static void handle_patch(const struct strbuf *line)
707
705
patch_lines ++ ;
708
706
}
709
707
710
- static void handle_filter (struct strbuf * line )
708
+ static void handle_filter (struct strbuf * line , int * filter_stage , int * header_stage )
711
709
{
712
- static int filter = 0 ;
713
-
714
- /* filter tells us which part we left off on */
715
- switch (filter ) {
710
+ switch (* filter_stage ) {
716
711
case 0 :
717
- if (!handle_commit_msg (line ))
712
+ if (!handle_commit_msg (line , header_stage ))
718
713
break ;
719
- filter ++ ;
714
+ ( * filter_stage ) ++ ;
720
715
case 1 :
721
716
handle_patch (line );
722
717
break ;
@@ -800,7 +795,7 @@ static int find_boundary(void)
800
795
return 0 ;
801
796
}
802
797
803
- static int handle_boundary (void )
798
+ static int handle_boundary (int * filter_stage , int * header_stage )
804
799
{
805
800
struct strbuf newline = STRBUF_INIT ;
806
801
@@ -822,7 +817,7 @@ static int handle_boundary(void)
822
817
"can't recover\n" );
823
818
exit (1 );
824
819
}
825
- handle_filter (& newline );
820
+ handle_filter (& newline , filter_stage , header_stage );
826
821
strbuf_release (& newline );
827
822
828
823
/* skip to the next boundary */
@@ -850,6 +845,8 @@ static int handle_boundary(void)
850
845
static void handle_body (void )
851
846
{
852
847
struct strbuf prev = STRBUF_INIT ;
848
+ int filter_stage = 0 ;
849
+ int header_stage = 1 ;
853
850
854
851
/* Skip up to the first boundary */
855
852
if (* content_top ) {
@@ -862,10 +859,10 @@ static void handle_body(void)
862
859
if (* content_top && is_multipart_boundary (& line )) {
863
860
/* flush any leftover */
864
861
if (prev .len ) {
865
- handle_filter (& prev );
862
+ handle_filter (& prev , & filter_stage , & header_stage );
866
863
strbuf_reset (& prev );
867
864
}
868
- if (!handle_boundary ())
865
+ if (!handle_boundary (& filter_stage , & header_stage ))
869
866
goto handle_body_out ;
870
867
}
871
868
@@ -895,7 +892,7 @@ static void handle_body(void)
895
892
strbuf_addbuf (& prev , sb );
896
893
break ;
897
894
}
898
- handle_filter (sb );
895
+ handle_filter (sb , & filter_stage , & header_stage );
899
896
}
900
897
/*
901
898
* The partial chunk is saved in "prev" and will be
@@ -905,7 +902,7 @@ static void handle_body(void)
905
902
break ;
906
903
}
907
904
default :
908
- handle_filter (& line );
905
+ handle_filter (& line , & filter_stage , & header_stage );
909
906
}
910
907
911
908
} while (!strbuf_getwholeline (& line , fin , '\n' ));
0 commit comments