Re: [PATCH] blame: Improve parsing for emails with spaces

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

 



On Thu, Apr 21, 2011 at 03:07:36PM -0700, Josh Stone wrote:

> One of my git repositories has some old commits where the authors
> obfuscated their email address as <author at example dot com>.  To
> handle this, blame needs to look for the leading '<' when scanning
> to split the "name <email>", rather then only a space delimiter.

Hmm. That address seems bogus, and I wonder if we should be rejecting it
at commit time. Still, it is something we may run across in existing
repositories, so handling it more gracefully makes sense.

> diff --git a/builtin/blame.c b/builtin/blame.c
> index f6b03f7..41525f1 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -1377,7 +1377,7 @@ static void get_ac_line(const char *inbuf, const char *what,
>  	timepos = tmp;
>  
>  	*tmp = 0;
> -	while (person < tmp && *tmp != ' ')
> +	while (person < tmp && !(*tmp == ' ' && tmp[1] == '<'))
>  		tmp--;
>  	if (tmp <= person)
>  		return;

The fix looks fine. It's a little gross that we are parsing the commit
headers ourselves here, as opposed to using some library function
provided for commits. I think we could eliminate some code by using
the parser in pretty.c, but it might need some refactoring to do so
efficiently.

Looking over the other places we parse author info, I don't think the
same problem exists elsewhere. Most other places parse from left to
right, and just go to the closing ">".

-Peff
--
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]