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