{"thread":{"id":"19463","subject":"[PATCH 1/2] mailinfo: handle StGit patches","startedAt":"2009-05-24T07:19:17Z","lastAt":"2009-05-24T07:19:17Z","messageCount":1,"participants":["Giuseppe Bilotta"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"114548","messageId":"1243149558-17160-2-git-send-email-giuseppe.bilotta@gmail.com","threadId":"19463","inReplyTo":null,"subject":"[PATCH 1/2] mailinfo: handle StGit patches","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-05-24T07:19:17Z","receivedAt":"2009-05-24T07:19:17Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"The default StGit export template puts author information in a From:\nline located between the subject and the body of the commit message.\nWe can handle these files by prepending 'Subject: ' to the first\nline of the file and skipping the whitespace following it.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n builtin-mailinfo.c |   18 ++++++++++++++++++\n 1 files changed, 18 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-mailinfo.c b/builtin-mailinfo.c\nindex 92637ac..67317e2 100644\n--- a/builtin-mailinfo.c\n+++ b/builtin-mailinfo.c\n@@ -920,6 +920,24 @@ static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,\n \t} while (isspace(peek));\n \tungetc(peek, in);\n \n+\t/* The default StGit export template has the subject as first line\n+\t   (without 'Subject:') followed by an empty line, followed by\n+\t   the author info (with 'From:'), followed by an empty line,\n+\t   followed by the body. If the first line is not a mail header\n+\t   and we add 'Subject:' in front of it, skipping the subsequent\n+\t   empty line(s), we can thus parse StGit patches.\n+\t   */\n+\tif (read_one_header_line(&line, fin))\n+\t\tcheck_header(&line, p_hdr_data, 1);\n+\telse {\n+\t\tstrbuf_insert(&line, 0, \"Subject: \", 9);\n+\t\tcheck_header(&line, p_hdr_data, 1);\n+\t\tdo {\n+\t\t\tpeek = fgetc(in);\n+\t\t} while (isspace(peek));\n+\t\tungetc(peek, in);\n+\t}\n+\n \t/* process the email header */\n \twhile (read_one_header_line(&line, fin))\n \t\tcheck_header(&line, p_hdr_data, 1);\n-- \n1.6.3.1.212.g6c0d3.dirty\n"}]}