Re: [PATCH 1/3] blame: fix email output with mailmap
- From
Jeff King <peff@peff.net>
- Date
- Feb 4, 2012, 23:39 UTC
- Message-ID
- <20120204233909.GA1366@sigill.intra.peff.net>
- In-Reply-To
- <1328385024-6955-2-git-send-email-felipe.contreras@gmail.com>
On Sat, Feb 04, 2012 at 09:50:22PM +0200, Felipe Contreras wrote:
Show 20 quoted lines
> diff --git a/builtin/blame.c b/builtin/blame.c
> index 5a67c20..dd69e51 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -1403,10 +1403,13 @@ static void get_ac_line(const char *inbuf, const char *what,
> * Now, convert both name and e-mail using mailmap
> */
> if (map_user(&mailmap, mail+1, mail_len-1, person, tmp-person-1)) {
> - /* Add a trailing '>' to email, since map_user returns plain emails
> - Note: It already has '<', since we replace from mail+1 */
> + /*
> + * Add a trailing '>' to email, since map_user returns plain
> + * emails when it finds a matching mail.
> + * Note: It already has '<', since we replace from mail + 1
> + */
> mailpos = memchr(mail, '\0', mail_len);
> - if (mailpos && mailpos-mail < mail_len - 1) {
> + if (mailpos && mailpos-mail < mail_len - 1 && *(mailpos - 1) != '>') {
> *mailpos = '>';
> *(mailpos+1) = '\0';I'm not sure if it's possible, but do you need to be checking that "mailpos > mail" to avoid reading off the beginning of the buffer? It would mean the email field is empty, which may or may not be possible.
-Peff