Skip to content

Commit 849106d

Browse files
committed
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 <[email protected]>
1 parent c69f239 commit 849106d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

builtin/mailinfo.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99

1010
static FILE *cmitmsg, *patchfile, *fin, *fout;
1111

12-
static int keep_subject;
13-
static int keep_non_patch_brackets_in_subject;
1412
static const char *metainfo_charset;
1513

1614
struct mailinfo {
1715
struct strbuf name;
1816
struct strbuf email;
17+
int keep_subject;
18+
int keep_non_patch_brackets_in_subject;
1919
};
2020
static char *message_id;
2121

@@ -232,7 +232,7 @@ static int is_multipart_boundary(const struct strbuf *line)
232232
!memcmp(line->buf, (*content_top)->buf, (*content_top)->len));
233233
}
234234

235-
static void cleanup_subject(struct strbuf *subject)
235+
static void cleanup_subject(struct mailinfo *mi, struct strbuf *subject)
236236
{
237237
size_t at = 0;
238238

@@ -260,7 +260,7 @@ static void cleanup_subject(struct strbuf *subject)
260260
if (!pos)
261261
break;
262262
remove = pos - subject->buf + at + 1;
263-
if (!keep_non_patch_brackets_in_subject ||
263+
if (!mi->keep_non_patch_brackets_in_subject ||
264264
(7 <= remove &&
265265
memmem(subject->buf + at, remove, "PATCH", 5)))
266266
strbuf_remove(subject, at, remove);
@@ -945,8 +945,8 @@ static void handle_info(struct mailinfo *mi)
945945
continue;
946946

947947
if (!strcmp(header[i], "Subject")) {
948-
if (!keep_subject) {
949-
cleanup_subject(hdr);
948+
if (!mi->keep_subject) {
949+
cleanup_subject(mi, hdr);
950950
cleanup_space(hdr);
951951
}
952952
output_header_lines(fout, "Subject", hdr);
@@ -1049,9 +1049,9 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
10491049

10501050
while (1 < argc && argv[1][0] == '-') {
10511051
if (!strcmp(argv[1], "-k"))
1052-
keep_subject = 1;
1052+
mi.keep_subject = 1;
10531053
else if (!strcmp(argv[1], "-b"))
1054-
keep_non_patch_brackets_in_subject = 1;
1054+
mi.keep_non_patch_brackets_in_subject = 1;
10551055
else if (!strcmp(argv[1], "-m") || !strcmp(argv[1], "--message-id"))
10561056
add_message_id = 1;
10571057
else if (!strcmp(argv[1], "-u"))

0 commit comments

Comments
 (0)