Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
mailinfo: move [ps]_hdr_data to struct mailinfo
author
Junio C Hamano
<gitster@pobox.com>
Thu, 15 Oct 2015 00:43:24 +0000
(17:43 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 21 Oct 2015 22:56:17 +0000
(15:56 -0700)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/mailinfo.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
8f63588
)
diff --git
a/builtin/mailinfo.c
b/builtin/mailinfo.c
index f57100f2cee886e093ac062095d7f6426a45765c..315d542188b506f8d80ca08f49a6f9dfd60443c7 100644
(file)
--- a/
builtin/mailinfo.c
+++ b/
builtin/mailinfo.c
@@
-30,10
+30,10
@@
struct mailinfo {
int patch_lines;
int filter_stage; /* still reading log or are we copying patch? */
int header_stage; /* still checking in-body headers? */
int patch_lines;
int filter_stage; /* still reading log or are we copying patch? */
int header_stage; /* still checking in-body headers? */
+ struct strbuf **p_hdr_data;
+ struct strbuf **s_hdr_data;
};
};
-static struct strbuf **p_hdr_data, **s_hdr_data;
-
#define MAX_BOUNDARIES 5
static void cleanup_space(struct strbuf *sb)
#define MAX_BOUNDARIES 5
static void cleanup_space(struct strbuf *sb)
@@
-663,7
+663,7
@@
static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
}
if (mi->use_inbody_headers && mi->header_stage) {
}
if (mi->use_inbody_headers && mi->header_stage) {
- mi->header_stage = check_header(mi, line, s_hdr_data, 0);
+ mi->header_stage = check_header(mi, line,
mi->
s_hdr_data, 0);
if (mi->header_stage)
return 0;
} else
if (mi->header_stage)
return 0;
} else
@@
-688,9
+688,9
@@
static int handle_commit_msg(struct mailinfo *mi, struct strbuf *line)
* them to give ourselves a clean restart.
*/
for (i = 0; header[i]; i++) {
* them to give ourselves a clean restart.
*/
for (i = 0; header[i]; i++) {
- if (s_hdr_data[i])
- strbuf_release(s_hdr_data[i]);
- s_hdr_data[i] = NULL;
+ if (
mi->
s_hdr_data[i])
+ strbuf_release(
mi->
s_hdr_data[i]);
+
mi->
s_hdr_data[i] = NULL;
}
return 0;
}
}
return 0;
}
@@
-840,7
+840,7
@@
static int handle_boundary(struct mailinfo *mi, struct strbuf *line)
/* slurp in this section's info */
while (read_one_header_line(line, mi->input))
/* slurp in this section's info */
while (read_one_header_line(line, mi->input))
- check_header(mi, line, p_hdr_data, 0);
+ check_header(mi, line,
mi->
p_hdr_data, 0);
strbuf_release(&newline);
/* replenish line */
strbuf_release(&newline);
/* replenish line */
@@
-941,10
+941,10
@@
static void handle_info(struct mailinfo *mi)
for (i = 0; header[i]; i++) {
/* only print inbody headers if we output a patch file */
for (i = 0; header[i]; i++) {
/* only print inbody headers if we output a patch file */
- if (mi->patch_lines && s_hdr_data[i])
- hdr = s_hdr_data[i];
- else if (p_hdr_data[i])
- hdr = p_hdr_data[i];
+ if (mi->patch_lines &&
mi->
s_hdr_data[i])
+ hdr =
mi->
s_hdr_data[i];
+ else if (
mi->
p_hdr_data[i])
+ hdr =
mi->
p_hdr_data[i];
else
continue;
else
continue;
@@
-984,8
+984,8
@@
static int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
return -1;
}
return -1;
}
-
p_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(*p_hdr_data
));
-
s_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(*s_hdr_data
));
+
mi->p_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(*(mi->p_hdr_data)
));
+
mi->s_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(*(mi->s_hdr_data)
));
do {
peek = fgetc(mi->input);
do {
peek = fgetc(mi->input);
@@
-994,7
+994,7
@@
static int mailinfo(struct mailinfo *mi, const char *msg, const char *patch)
/* process the email header */
while (read_one_header_line(&line, mi->input))
/* process the email header */
while (read_one_header_line(&line, mi->input))
- check_header(mi, &line, p_hdr_data, 1);
+ check_header(mi, &line,
mi->
p_hdr_data, 1);
handle_body(mi, &line);
fclose(mi->patchfile);
handle_body(mi, &line);
fclose(mi->patchfile);
@@
-1031,10
+1031,19
@@
static void setup_mailinfo(struct mailinfo *mi)
static void clear_mailinfo(struct mailinfo *mi)
{
static void clear_mailinfo(struct mailinfo *mi)
{
+ int i;
+
strbuf_release(&mi->name);
strbuf_release(&mi->email);
strbuf_release(&mi->charset);
free(mi->message_id);
strbuf_release(&mi->name);
strbuf_release(&mi->email);
strbuf_release(&mi->charset);
free(mi->message_id);
+
+ for (i = 0; mi->p_hdr_data[i]; i++)
+ strbuf_release(mi->p_hdr_data[i]);
+ free(mi->p_hdr_data);
+ for (i = 0; mi->s_hdr_data[i]; i++)
+ strbuf_release(mi->s_hdr_data[i]);
+ free(mi->s_hdr_data);
}
static const char mailinfo_usage[] =
}
static const char mailinfo_usage[] =