mailinfo: move keep_subject & keep_non_patch_bracket to struct mailinfo

These two are the only easy ones that do not require passing the structure around to deep corners of the callchain. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Oct 14, 2015 at 15:39 UTC 849106d5116e62d36070249f01adefc02cff157e
1 file changed +8 -8
builtin/mailinfo.c
+8 -8
@@ -9,13 +9,13 @@
9
10 static FILE *cmitmsg, *patchfile, *fin, *fout;
11
12 -static int keep_subject;
13 -static int keep_non_patch_brackets_in_subject;
12 static const char *metainfo_charset;
13
14 struct mailinfo {
15 struct strbuf name;
16 struct strbuf email;
17 + int keep_subject;
18 + int keep_non_patch_brackets_in_subject;
19 };
20 static char *message_id;
21
@@ -232,7 +232,7 @@ static int is_multipart_boundary(const struct strbuf *line)
232 !memcmp(line->buf, (*content_top)->buf, (*content_top)->len));
233 }
234
235 -static void cleanup_subject(struct strbuf *subject)
235 +static void cleanup_subject(struct mailinfo *mi, struct strbuf *subject)
236 {
237 size_t at = 0;
238
@@ -260,7 +260,7 @@ static void cleanup_subject(struct strbuf *subject)
260 if (!pos)
261 break;
262 remove = pos - subject->buf + at + 1;
263 - if (!keep_non_patch_brackets_in_subject ||
263 + if (!mi->keep_non_patch_brackets_in_subject ||
264 (7 <= remove &&
265 memmem(subject->buf + at, remove, "PATCH", 5)))
266 strbuf_remove(subject, at, remove);
@@ -945,8 +945,8 @@ static void handle_info(struct mailinfo *mi)
945 continue;
946
947 if (!strcmp(header[i], "Subject")) {
948 - if (!keep_subject) {
949 - cleanup_subject(hdr);
948 + if (!mi->keep_subject) {
949 + cleanup_subject(mi, hdr);
950 cleanup_space(hdr);
951 }
952 output_header_lines(fout, "Subject", hdr);
@@ -1049,9 +1049,9 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
1049
1050 while (1 < argc && argv[1][0] == '-') {
1051 if (!strcmp(argv[1], "-k"))
1052 - keep_subject = 1;
1052 + mi.keep_subject = 1;
1053 else if (!strcmp(argv[1], "-b"))
1054 - keep_non_patch_brackets_in_subject = 1;
1054 + mi.keep_non_patch_brackets_in_subject = 1;
1055 else if (!strcmp(argv[1], "-m") || !strcmp(argv[1], "--message-id"))
1056 add_message_id = 1;
1057 else if (!strcmp(argv[1], "-u"))