With the pregvious step, it becomes clear that the mailinfo() function is the only one that wants the "line_global" to be directly touchable. Logically, this strbuf belongs to handle_body(). It passes the line to its helper functions for processing, and keeps one line at a time into the variable in the loop to drive that process. It would have been even nicer looking if we could make the variable local to the function. But the function has to be passed its initial value (i.e. the first line is read by its caller), and that is why its sole caller owns it in the resulting code structure. Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx> --- builtin/mailinfo.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index 721d999..c8dc73f 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; @@ -966,6 +965,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; @@ -990,10 +991,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); fclose(patchfile); handle_info(); -- 2.6.1-320-g86a1181 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html