Skip to content

Commit 8f63588

Browse files
committed
mailinfo: move cmitmsg and patchfile to struct mailinfo
Signed-off-by: Junio C Hamano <[email protected]>
1 parent f1e037b commit 8f63588

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

builtin/mailinfo.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#include "utf8.h"
88
#include "strbuf.h"
99

10-
static FILE *cmitmsg, *patchfile;
11-
1210
struct mailinfo {
1311
FILE *input;
1412
FILE *output;
13+
FILE *cmitmsg;
14+
FILE *patchfile;
1515

1616
struct strbuf name;
1717
struct strbuf email;
@@ -654,7 +654,7 @@ static int is_scissors_line(const struct strbuf *line)
654654

655655
static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
656656
{
657-
if (!cmitmsg)
657+
if (!mi->cmitmsg)
658658
return 0;
659659

660660
if (mi->header_stage) {
@@ -677,9 +677,9 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
677677

678678
if (mi->use_scissors && is_scissors_line(line)) {
679679
int i;
680-
if (fseek(cmitmsg, 0L, SEEK_SET))
680+
if (fseek(mi->cmitmsg, 0L, SEEK_SET))
681681
die_errno("Could not rewind output message file");
682-
if (ftruncate(fileno(cmitmsg), 0))
682+
if (ftruncate(fileno(mi->cmitmsg), 0))
683683
die_errno("Could not truncate output message file at scissors");
684684
mi->header_stage = 1;
685685

@@ -697,19 +697,19 @@ static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
697697

698698
if (patchbreak(line)) {
699699
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;
703703
return 1;
704704
}
705705

706-
fputs(line->buf, cmitmsg);
706+
fputs(line->buf, mi->cmitmsg);
707707
return 0;
708708
}
709709

710710
static void handle_patch(struct mailinfo *mi, const struct strbuf *line)
711711
{
712-
fwrite(line->buf, 1, line->len, patchfile);
712+
fwrite(line->buf, 1, line->len, mi->patchfile);
713713
mi->patch_lines++;
714714
}
715715

@@ -972,15 +972,15 @@ static int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
972972
int peek;
973973
struct strbuf line = STRBUF_INIT;
974974

975-
cmitmsg = fopen(msg, "w");
976-
if (!cmitmsg) {
975+
mi->cmitmsg = fopen(msg, "w");
976+
if (!mi->cmitmsg) {
977977
perror(msg);
978978
return -1;
979979
}
980-
patchfile = fopen(patch, "w");
981-
if (!patchfile) {
980+
mi->patchfile = fopen(patch, "w");
981+
if (!mi->patchfile) {
982982
perror(patch);
983-
fclose(cmitmsg);
983+
fclose(mi->cmitmsg);
984984
return -1;
985985
}
986986

@@ -997,7 +997,7 @@ static int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
997997
check_header(mi, &line, p_hdr_data, 1);
998998

999999
handle_body(mi, &line);
1000-
fclose(patchfile);
1000+
fclose(mi->patchfile);
10011001

10021002
handle_info(mi);
10031003
strbuf_release(&line);

0 commit comments

Comments
 (0)