7
7
#include "utf8.h"
8
8
#include "strbuf.h"
9
9
10
- static FILE * cmitmsg , * patchfile ;
11
-
12
10
struct mailinfo {
13
11
FILE * input ;
14
12
FILE * output ;
13
+ FILE * cmitmsg ;
14
+ FILE * patchfile ;
15
15
16
16
struct strbuf name ;
17
17
struct strbuf email ;
@@ -654,7 +654,7 @@ static int is_scissors_line(const struct strbuf *line)
654
654
655
655
static int handle_commit_msg (struct mailinfo * mi , struct strbuf * line )
656
656
{
657
- if (!cmitmsg )
657
+ if (!mi -> cmitmsg )
658
658
return 0 ;
659
659
660
660
if (mi -> header_stage ) {
@@ -677,9 +677,9 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
677
677
678
678
if (mi -> use_scissors && is_scissors_line (line )) {
679
679
int i ;
680
- if (fseek (cmitmsg , 0L , SEEK_SET ))
680
+ if (fseek (mi -> cmitmsg , 0L , SEEK_SET ))
681
681
die_errno ("Could not rewind output message file" );
682
- if (ftruncate (fileno (cmitmsg ), 0 ))
682
+ if (ftruncate (fileno (mi -> cmitmsg ), 0 ))
683
683
die_errno ("Could not truncate output message file at scissors" );
684
684
mi -> header_stage = 1 ;
685
685
@@ -697,19 +697,19 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
697
697
698
698
if (patchbreak (line )) {
699
699
if (mi -> message_id )
700
- fprintf (cmitmsg , "Message-Id: %s\n" , mi -> message_id );
701
- fclose (cmitmsg );
702
- cmitmsg = NULL ;
700
+ fprintf (mi -> cmitmsg , "Message-Id: %s\n" , mi -> message_id );
701
+ fclose (mi -> cmitmsg );
702
+ mi -> cmitmsg = NULL ;
703
703
return 1 ;
704
704
}
705
705
706
- fputs (line -> buf , cmitmsg );
706
+ fputs (line -> buf , mi -> cmitmsg );
707
707
return 0 ;
708
708
}
709
709
710
710
static void handle_patch (struct mailinfo * mi , const struct strbuf * line )
711
711
{
712
- fwrite (line -> buf , 1 , line -> len , patchfile );
712
+ fwrite (line -> buf , 1 , line -> len , mi -> patchfile );
713
713
mi -> patch_lines ++ ;
714
714
}
715
715
@@ -972,15 +972,15 @@ static int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
972
972
int peek ;
973
973
struct strbuf line = STRBUF_INIT ;
974
974
975
- cmitmsg = fopen (msg , "w" );
976
- if (!cmitmsg ) {
975
+ mi -> cmitmsg = fopen (msg , "w" );
976
+ if (!mi -> cmitmsg ) {
977
977
perror (msg );
978
978
return -1 ;
979
979
}
980
- patchfile = fopen (patch , "w" );
981
- if (!patchfile ) {
980
+ mi -> patchfile = fopen (patch , "w" );
981
+ if (!mi -> patchfile ) {
982
982
perror (patch );
983
- fclose (cmitmsg );
983
+ fclose (mi -> cmitmsg );
984
984
return -1 ;
985
985
}
986
986
@@ -997,7 +997,7 @@ static int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
997
997
check_header (mi , & line , p_hdr_data , 1 );
998
998
999
999
handle_body (mi , & line );
1000
- fclose (patchfile );
1000
+ fclose (mi -> patchfile );
1001
1001
1002
1002
handle_info (mi );
1003
1003
strbuf_release (& line );
0 commit comments