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

'git mailinfo' whitespace bug

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 18, 2010, 18:05 UTC
Message-ID
<alpine.LFD.2.00.1002180936240.4141@localhost.localdomain>

'git mailinfo' removes the whitespace from the beginning of the email body, but it does it incorrectly.

In particular, some people use indented paragraphs, like this:
	  Four-score and Four score and seven years ago our fathers 
   brought forth, upon this continent, a new nation, conceived in Liberty, 
   and dedicated to the proposition that all men are created equal.
	Now we are engaged in a great civil war, testing whether that 
   nation, or any nation so conceived, and so dedicated, can long endure. 
   We are met here on a great battlefield of that war. We have come to 
   dedicate a portion of it as a final resting place for those who here 
   gave their lives that that nation might live. It is altogether fitting 
   and proper that we should do this.
   ...

and mailinfo will not just remove empty lines from the beginning of the email body, it will also remove the _first_ indentation (but not any others). Which makes the whole thing come out wrong.

I bisected it, and this bug was introduced almost two years ago. In commit 3b6121f69b2 ("git-mailinfo: use strbuf's instead of fixed buffers"), to be exact. I'm pretty sure the bug is that handle_commit_msg() was changed to use 'strbuf_ltrim()' for the 'still_looking' case.

Before commit 3b6121f69b2, it would create a new variable that had the trimmed results ("char *cp = line;"), after that commit it would just trim the line itself. Which is correct for the case of it being a header, but if it's the first non-header line, it's wrong.

			Linus
Next: Lukas Sandström
Message 1 of 5 in “'git mailinfo' whitespace bug”
  1. Linus TorvaldsFeb 18, 2010
  2. mailinfo: don't trim whitespace in the commit messageLukas Sandström, Feb 19, 2010
  3. Junio C HamanoFeb 20, 2010
  4. Don ZickusFeb 22, 2010
  5. Junio C HamanoFeb 22, 2010

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.