From: Junio C Hamano Date: Tue, 13 Oct 2015 23:16:28 GMT Subject: [PATCH 07/26] mailinfo: move global "line" into mailinfo() function Message-ID: <1444778207-859-8-git-send-email-gitster@pobox.com> In-Reply-To: <1444778207-859-1-git-send-email-gitster@pobox.com> The mailinfo() function is the only one that wants the "line_global" to be directly touchable. Note that handle_body() has to be passed this strbuf so that it sees the "first line of the input" after the loop in this function processes the headers. It feels a bit dirty that handle_body() then keeps reusing this strbuf to read more lines and does its processing, but that is how the code is structured now. Signed-off-by: Junio C Hamano --- builtin/mailinfo.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index c3c7d67..6c671fb 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -12,7 +12,6 @@ static FILE *cmitmsg, *patchfile, *fin, *fout; static int keep_subject; static int keep_non_patch_brackets_in_subject; static const char *metainfo_charset; -static struct strbuf line_global = STRBUF_INIT; static struct strbuf name = STRBUF_INIT; static struct strbuf email = STRBUF_INIT; static char *message_id; @@ -995,6 +994,8 @@ static void handle_info(void) static int mailinfo(FILE *in, FILE *out, const char *msg, const char *patch) { int peek; + struct strbuf line = STRBUF_INIT; + fin = in; fout = out; @@ -1019,10 +1020,10 @@ static int mailinfo(FILE *in, FILE *out, const char *msg, const char *patch) ungetc(peek, in); /* process the email header */ - while (read_one_header_line(&line_global, fin)) - check_header(&line_global, p_hdr_data, 1); + while (read_one_header_line(&line, fin)) + check_header(&line, p_hdr_data, 1); - handle_body(&line_global); + handle_body(&line); handle_info(); return 0; -- 2.6.1-320-g86a1181