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

[PATCH 2/4] mailmap: do not downcase mailmap entries

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 12, 2013, 21:38 UTC
Message-ID
<1373665135-32484-3-git-send-email-gitster@pobox.com>
In-Reply-To
<1373665135-32484-1-git-send-email-gitster@pobox.com>

The email addresses in the records read from the .mailmap file are downcased very early, and then used to match against e-mail addresses in the input. Because we do use case insensitive version of string list to manage these entries, there is no need to do this, and worse yet, downcasing the rewritten/canonical e-mail read from the .mailmap file loses information.

Stop doing that, and also make the string list used to keep multiple names for an mailmap entry case insensitive (the code that uses the list, lookup_prefix(), expects a case insensitive match).

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 mailmap.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/mailmap.c b/mailmap.c
index 418081e..a7e92db 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -51,14 +51,6 @@ static void add_mapping(struct string_list *map,
 {
 	struct mailmap_entry *me;
 	int index;
-	char *p;
-
-	if (old_email)
-		for (p = old_email; *p; p++)
-			*p = tolower(*p);
-	if (new_email)
-		for (p = new_email; *p; p++)
-			*p = tolower(*p);
 
 	if (old_email == NULL) {
 		old_email = new_email;
@@ -68,13 +60,17 @@ static void add_mapping(struct string_list *map,
 	if ((index = string_list_find_insert_index(map, old_email, 1)) < 0) {
 		/* mailmap entry exists, invert index value */
 		index = -1 - index;
+		me = (struct mailmap_entry *)map->items[index].util;
 	} else {
 		/* create mailmap entry */
-		struct string_list_item *item = string_list_insert_at_index(map, index, old_email);
-		item->util = xcalloc(1, sizeof(struct mailmap_entry));
-		((struct mailmap_entry *)item->util)->namemap.strdup_strings = 1;
+		struct string_list_item *item;
+
+		item = string_list_insert_at_index(map, index, old_email);
+		me = xcalloc(1, sizeof(struct mailmap_entry));
+		me->namemap.strdup_strings = 1;
+		me->namemap.cmp = strcasecmp;
+		item->util = me;
 	}
-	me = (struct mailmap_entry *)map->items[index].util;
 
 	if (old_name == NULL) {
 		debug_mm("mailmap: adding (simple) entry for %s at index %d\n", old_email, index);
-- 
1.8.3.2-941-gda9c3c8
Previous: Eric SunshineNext: Junio C Hamano
Message 10 of 14 in “Microfixes to mailmap”
  1. 0/4 Microfixes to mailmapJunio C Hamano, Jul 12, 2013
  2. 1/4 mailmap: do not lose single-letter namesJunio C Hamano, Jul 12, 2013
  3. mailmap: Testing the single letter name case.Stefan Beller, Jul 13, 2013
  4. Junio C HamanoJul 13, 2013
  5. Stefan BellerJul 13, 2013
  6. Junio C HamanoJul 13, 2013
  7. Eric SunshineJul 15, 2013
  8. Junio C HamanoJul 15, 2013
  9. Eric SunshineJul 14, 2013
  10. 2/4 mailmap: do not downcase mailmap entriesJunio C Hamano, Jul 12, 2013
  11. 3/4 mailmap: style fixesJunio C Hamano, Jul 12, 2013
  12. 4/4 add a testcase for checking case insensitivity of mailmapJunio C Hamano, Jul 12, 2013
  13. Eric SunshineJul 12, 2013
  14. Eric SunshineJul 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.