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

[PATCH] Make git-mailinfo strip whitespace from the start of the mail file.

From
SSSimon Sasburg <simon.sasburg@gmail.com>
Date
Nov 1, 2007, 21:05 UTC
Message-ID
<1193951139-2312-1-git-send-email-Simon.Sasburg@gmail.com>
This allows you to use files gotten through gmail's web interface via its 'Show original' option.
Signed-off-by: Simon Sasburg <Simon.Sasburg@gmail.com>
---
Note that this doesn't exactly follow RFC 2822 as far as i can see, but i don't know if git prefers to be strict or tolerant in these cases, so i'm sending the patch anyway.
It certaily helps me, even if just a little bit.
 builtin-mailinfo.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index fb12248..5d4b6bf 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -915,6 +915,7 @@ static void handle_info(void)
 static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
 		    const char *msg, const char *patch)
 {
+	int peek;
 	keep_subject = ks;
 	metainfo_charset = encoding;
 	fin = in;
@@ -935,6 +936,11 @@ static int mailinfo(FILE *in, FILE *out, int ks, const char *encoding,
 	p_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(char *));
 	s_hdr_data = xcalloc(MAX_HDR_PARSED, sizeof(char *));
 
+	do {
+		peek = fgetc(in);
+	} while (peek == ' ' || peek == '\r' || peek == '\n');
+	ungetc(peek, in);
+
 	/* process the email header */
 	while (read_one_header_line(line, sizeof(line), fin))
 		check_header(line, sizeof(line), p_hdr_data, 1);
-- 
1.5.3.4.502.g37c97
Next: Junio C Hamano
Message 1 of 7 in “Make git-mailinfo strip whitespace from the start of the mail file.”
  1. Make git-mailinfo strip whitespace from the start of the mail file.Simon Sasburg, Nov 1, 2007
  2. Junio C HamanoNov 1, 2007
  3. Simon SasburgNov 1, 2007
  4. Junio C HamanoNov 1, 2007
  5. Make git-mailsplit strip whitespace from the start of the mailbox file.Simon Sasburg, Nov 1, 2007
  6. Junio C HamanoNov 2, 2007
  7. Make git-mailsplit strip whitespace from the start of the mailbox file.Simon Sasburg, Nov 4, 2007

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.