git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Git Mailing List" <git@vger.kernel.org>,
	"Lukas Sandström" <lukass@etek.chalmers.se>,
	"Don Zickus" <dzickus@redhat.com>
Subject: Re: 'git mailinfo' whitespace bug
Date: Fri, 19 Feb 2010 21:51:19 -0800	[thread overview]
Message-ID: <7vzl343160.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LFD.2.00.1002180936240.4141@localhost.localdomain> (Linus Torvalds's message of "Thu\, 18 Feb 2010 10\:05\:27 -0800 \(PST\)")

Linus Torvalds <torvalds@linux-foundation.org> writes:

> 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.

True; trimming the body is obviously wrong.

But when is it correct to ltrim a header line?  It means we are going to
accept a header (or header-looking line in body) that is indented.  I
don't know why 87ab799 (builtin-mailinfo.c 2007-03-12) was coded that way.


 builtin-mailinfo.c |    3 +--
 t/t5100/msg0015    |    2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index a50ac22..ce2ef6b 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -779,8 +779,7 @@ static int handle_commit_msg(struct strbuf *line)
 		return 0;
 
 	if (still_looking) {
-		strbuf_ltrim(line);
-		if (!line->len)
+		if (!line->len || (line->len == 1 && line->buf[0] == '\n'))
 			return 0;
 	}
 
diff --git a/t/t5100/msg0015 b/t/t5100/msg0015
index 9577238..4abb3d5 100644
--- a/t/t5100/msg0015
+++ b/t/t5100/msg0015
@@ -1,2 +1,2 @@
-- a list
+  - a list
   - of stuff

  parent reply	other threads:[~2010-02-20  5:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-18 18:05 'git mailinfo' whitespace bug Linus Torvalds
2010-02-19 11:54 ` [PATCH] mailinfo: don't trim whitespace in the commit message Lukas Sandström
2010-02-20  5:51 ` Junio C Hamano [this message]
2010-02-22 15:13   ` 'git mailinfo' whitespace bug Don Zickus
2010-02-22 19:57     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vzl343160.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=dzickus@redhat.com \
    --cc=git@vger.kernel.org \
    --cc=lukass@etek.chalmers.se \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).