git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] mailinfo: handle StGit patches

From
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Date
May 24, 2009, 07:19 UTC
Message-ID
<1243149558-17160-2-git-send-email-giuseppe.bilotta@gmail.com>

The default StGit export template puts author information in a From: line located between the subject and the body of the commit message. We can handle these files by prepending 'Subject: ' to the first line of the file and skipping the whitespace following it.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
 builtin-mailinfo.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 92637ac..67317e2 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -920,6 +920,24 @@ static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
 	} while (isspace(peek));
 	ungetc(peek, in);
 
+	/* The default StGit export template has the subject as first line
+	   (without 'Subject:') followed by an empty line, followed by
+	   the author info (with 'From:'), followed by an empty line,
+	   followed by the body. If the first line is not a mail header
+	   and we add 'Subject:' in front of it, skipping the subsequent
+	   empty line(s), we can thus parse StGit patches.
+	   */
+	if (read_one_header_line(&line, fin))
+		check_header(&line, p_hdr_data, 1);
+	else {
+		strbuf_insert(&line, 0, "Subject: ", 9);
+		check_header(&line, p_hdr_data, 1);
+		do {
+			peek = fgetc(in);
+		} while (isspace(peek));
+		ungetc(peek, in);
+	}
+
 	/* process the email header */
 	while (read_one_header_line(&line, fin))
 		check_header(&line, p_hdr_data, 1);
-- 
1.6.3.1.212.g6c0d3.dirty
Message 1 of 1 in “mailinfo: handle StGit patches”
  1. 1/2 mailinfo: handle StGit patchesGiuseppe Bilotta, May 24, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.