Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
mailinfo: move cmitmsg and patchfile to struct mailinfo
author
Junio C Hamano
<gitster@pobox.com>
Wed, 14 Oct 2015 23:16:47 +0000
(16:16 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 21 Oct 2015 22:55:01 +0000
(15:55 -0700)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/mailinfo.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
f1e037b
)
diff --git
a/builtin/mailinfo.c
b/builtin/mailinfo.c
index 1fd29f68207bc6476b55a8ab5864a13b094f09f9..f57100f2cee886e093ac062095d7f6426a45765c 100644
(file)
--- a/
builtin/mailinfo.c
+++ b/
builtin/mailinfo.c
@@
-7,11
+7,11
@@
#include "utf8.h"
#include "strbuf.h"
#include "utf8.h"
#include "strbuf.h"
-static FILE *cmitmsg, *patchfile;
-
struct mailinfo {
FILE *input;
FILE *output;
struct mailinfo {
FILE *input;
FILE *output;
+ FILE *cmitmsg;
+ FILE *patchfile;
struct strbuf name;
struct strbuf email;
struct strbuf name;
struct strbuf email;
@@
-654,7
+654,7
@@
static int is_scissors_line(const struct strbuf *line)
static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
{
static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
{
- if (!cmitmsg)
+ if (!
mi->
cmitmsg)
return 0;
if (mi->header_stage) {
return 0;
if (mi->header_stage) {
@@
-677,9
+677,9
@@
static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
if (mi->use_scissors && is_scissors_line(line)) {
int i;
if (mi->use_scissors && is_scissors_line(line)) {
int i;
- if (fseek(cmitmsg, 0L, SEEK_SET))
+ if (fseek(
mi->
cmitmsg, 0L, SEEK_SET))
die_errno("Could not rewind output message file");
die_errno("Could not rewind output message file");
- if (ftruncate(fileno(cmitmsg), 0))
+ if (ftruncate(fileno(
mi->
cmitmsg), 0))
die_errno("Could not truncate output message file at scissors");
mi->header_stage = 1;
die_errno("Could not truncate output message file at scissors");
mi->header_stage = 1;
@@
-697,19
+697,19
@@
static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
if (patchbreak(line)) {
if (mi->message_id)
if (patchbreak(line)) {
if (mi->message_id)
- fprintf(cmitmsg, "Message-Id: %s\n", mi->message_id);
- fclose(cmitmsg);
- cmitmsg = NULL;
+ fprintf(
mi->
cmitmsg, "Message-Id: %s\n", mi->message_id);
+ fclose(
mi->
cmitmsg);
+
mi->
cmitmsg = NULL;
return 1;
}
return 1;
}
- fputs(line->buf, cmitmsg);
+ fputs(line->buf,
mi->
cmitmsg);
return 0;
}
static void handle_patch(struct mailinfo *mi, const struct strbuf *line)
{
return 0;
}
static void handle_patch(struct mailinfo *mi, const struct strbuf *line)
{
- fwrite(line->buf, 1, line->len, patchfile);
+ fwrite(line->buf, 1, line->len,
mi->
patchfile);
mi->patch_lines++;
}
mi->patch_lines++;
}
@@
-972,15
+972,15
@@
static int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
int peek;
struct strbuf line = STRBUF_INIT;
int peek;
struct strbuf line = STRBUF_INIT;
- cmitmsg = fopen(msg, "w");
- if (!cmitmsg) {
+
mi->
cmitmsg = fopen(msg, "w");
+ if (!
mi->
cmitmsg) {
perror(msg);
return -1;
}
perror(msg);
return -1;
}
- patchfile = fopen(patch, "w");
- if (!patchfile) {
+
mi->
patchfile = fopen(patch, "w");
+ if (!
mi->
patchfile) {
perror(patch);
perror(patch);
- fclose(cmitmsg);
+ fclose(
mi->
cmitmsg);
return -1;
}
return -1;
}
@@
-997,7
+997,7
@@
static int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
check_header(mi, &line, p_hdr_data, 1);
handle_body(mi, &line);
check_header(mi, &line, p_hdr_data, 1);
handle_body(mi, &line);
- fclose(patchfile);
+ fclose(
mi->
patchfile);
handle_info(mi);
strbuf_release(&line);
handle_info(mi);
strbuf_release(&line);