git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug in .mailmap handling?

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 12, 2013, 20:28 UTC
Message-ID
<7vfvvjjzee.fsf@alter.siamese.dyndns.org>
In-Reply-To
<51E029B9.20108@googlemail.com>
Stefan Beller <stefanbeller@googlemail.com> writes:
> 	# Adding the line to the mailmap should make life easy, so we know
> 	# it's the same person
> 	echo "A <A@example.org> <changed_email@example.org>" > .mailmap
While I was looking at this, I noticed this piece of code:
diff --git a/mailmap.c b/mailmap.c
index 2a7b366..418081e 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -122,7 +122,7 @@ static char *parse_name_and_email(char *buffer, char **name,
 	while (nend > nstart && isspace(*nend))
 		--nend;
 
-	*name = (nstart < nend ? nstart : NULL);
+	*name = (nstart <= nend ? nstart : NULL);
 	*email = left+1;
 	*(nend+1) = '\0';
 	*right++ = '\0';

The function is given a buffer "A <A@example.org>...", nstart scans
from the beginning of the buffer, skipping whitespaces (there isn't
any, so nstart points at the buffer), while nend starts from one
byte before the first '<' and skips whitespaces backwards and ends
at the first non-whitespace (i.e. it hits "A" at the beginning of
the buffer).  nstart == nend in this case for a single-letter name,
and an off-by-one error makes it fail to pick up the name, which
makes the entry equivalent to

	<A@example.org> <changed_email@example.org>

without the name.  I do not think this bug affected anything you
observed, though.

> 	git shortlog -sne
> 		 1  A <A@example.org>
> 		 1  A <a@example.org>

This is coming from mailmap.c::add_mapping() that downcases the
e-mail address.

changed_email@example.org is mapped to a@example.org because of this
downcasing, while "A <A@example.org>" does not have any entry for it
in the .mailmap file, so it is given back as-is.  Hence we see two
distinct entries.
Previous: Stefan BellerNext: Stefan Beller
Message 4 of 8 in “Bug in .mailmap handling?”
  1. Stefan BellerJul 12, 2013
  2. Junio C HamanoJul 12, 2013
  3. Stefan BellerJul 12, 2013
  4. Junio C HamanoJul 12, 2013
  5. Stefan BellerJul 12, 2013
  6. Junio C HamanoJul 12, 2013
  7. Junio C HamanoJul 12, 2013
  8. Add a testcase for checking case insensitivity of mail mapStefan Beller, Jul 12, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.