Re: 'git mailinfo' whitespace bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 19, 2010 at 09:51:19PM -0800, Junio C Hamano wrote:
> Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> 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.

In regards to 87ab799, I just deleted and pasted it from the function
handle_inbody_header (which you can see from that commit).  The original
code for those lines came from ae448e3854d8b6e7e37aa88fa3917f5dd97f3210.
Perhaps I misused it when I moved it.

Your patch belows seems to make sense for what its worth.

Cheers,
Don

> 
> 
>  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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]