From: Jeff King <peff@peff.net>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: "Junio C Hamano" <gitster@pobox.com>,
"Jonathan Nieder" <jrnieder@gmail.com>,
git@vger.kernel.org, "SZEDER Gábor" <szeder@ira.uka.de>
Subject: [bug] blame duplicates trailing ">" in mailmapped emails
Date: Sat, 4 Feb 2012 13:26:11 -0500 [thread overview]
Message-ID: <20120204182611.GA31091@sigill.intra.peff.net> (raw)
In-Reply-To: <CAMP44s2QdJ4+qgg4fF5-DOWHx3Btd0pTivTT9s_E=qqxg16YLQ@mail.gmail.com>
On Sat, Feb 04, 2012 at 05:46:05PM +0200, Felipe Contreras wrote:
> In any case, the one to blame for the header corruption is git:
> [...]
> f2bb9f88 (<spearce@spearce.org>> 2006-11-27 03:41:01 -0500 952)
>
> Notice the mail is wrong.
Ugh. The fault lies in this code:
$ sed -n 1405,1414p builtin/blame.c
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 */
mailpos = memchr(mail, '\0', mail_len);
if (mailpos && mailpos-mail < mail_len - 1) {
*mailpos = '>';
*(mailpos+1) = '\0';
}
}
}
But that comment is wrong. If there's no email mapping needed, map_user
will leave the "mail" buffer intact, in which case it will have the
trailing ">" (because we feed the address with enclosing angle
brackets). So while map_user tries to accept either "foo@example.com\0"
and "foo@example.com>", it is up to the contents of the mailmap whether
you get back something with the closing angle bracket or not. Which is a
pretty error-prone interface.
You can fix it with this:
diff --git a/builtin/blame.c b/builtin/blame.c
index 5a67c20..9b886fa 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1406,7 +1406,8 @@ static void get_ac_line(const char *inbuf, const char *what,
/* Add a trailing '>' to email, since map_user returns plain emails
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 > mail && *(mailpos-1) != '>') {
*mailpos = '>';
*(mailpos+1) = '\0';
}
but it feels like the fix should go into map_user. I tried a few things,
like "git log -1 --format=%aE", and couldn't find other code paths with
this problem. So presumably they are all feeding email addresses without
the closing ">" (so one option is to just say "map_user needs to get
NUL-terminated strings).
-Peff
next prev parent reply other threads:[~2012-02-04 18:26 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-02 1:15 [PATCH v3 0/4] completion: couple of cleanups Felipe Contreras
[not found] ` <1328145320-14071-2-git-send-email-felipe.contreras@gmail.com>
2012-02-02 8:16 ` [PATCH v3 1/4] completion: be nicer with zsh Jonathan Nieder
2012-02-02 8:34 ` Felipe Contreras
2012-02-02 9:10 ` Jonathan Nieder
2012-02-02 9:38 ` Felipe Contreras
2012-02-02 9:46 ` Jonathan Nieder
2012-02-02 10:18 ` Felipe Contreras
2012-02-02 8:48 ` Jonathan Nieder
2012-02-02 10:12 ` Felipe Contreras
2012-02-02 10:35 ` Thomas Rast
2012-02-02 10:50 ` Jonathan Nieder
2012-02-02 10:55 ` Jonathan Nieder
2012-02-02 11:00 ` Felipe Contreras
2012-02-02 19:27 ` Junio C Hamano
2012-02-02 20:45 ` Felipe Contreras
2012-02-03 0:17 ` Junio C Hamano
2012-02-03 10:38 ` Felipe Contreras
2012-02-03 20:28 ` Junio C Hamano
2012-02-04 15:46 ` Felipe Contreras
2012-02-04 18:26 ` Jeff King [this message]
2012-02-04 19:30 ` [bug] blame duplicates trailing ">" in mailmapped emails Felipe Contreras
2012-02-04 23:20 ` Jeff King
2012-02-05 21:11 ` Felipe Contreras
2012-02-05 23:50 ` Jeff King
2012-02-05 20:16 ` Junio C Hamano
2012-02-05 21:38 ` Junio C Hamano
2012-02-05 23:47 ` Jeff King
2012-02-06 0:39 ` Junio C Hamano
2012-02-06 3:03 ` Jeff King
2012-02-06 3:13 ` Junio C Hamano
2012-02-06 3:16 ` Junio C Hamano
2012-02-06 4:01 ` Jeff King
2012-02-06 12:14 ` Felipe Contreras
2012-02-06 22:04 ` Junio C Hamano
2012-02-06 23:11 ` Felipe Contreras
2012-02-05 20:49 ` [PATCH v3 1/4] completion: be nicer with zsh Junio C Hamano
2012-02-02 9:05 ` [PATCH v3 2/4] completion: simplify __git_remotes Jonathan Nieder
2012-02-02 19:48 ` [PATCH v3 0/4] completion: couple of cleanups 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=20120204182611.GA31091@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=szeder@ira.uka.de \
/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).