Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 97e751b

Browse files
committed
mailmap: do not downcase mailmap entries
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 <[email protected]> Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3aff56d commit 97e751b

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

mailmap.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ static void add_mapping(struct string_list *map,
5151
{
5252
struct mailmap_entry *me;
5353
int index;
54-
char *p;
55-
56-
if (old_email)
57-
for (p = old_email; *p; p++)
58-
*p = tolower(*p);
59-
if (new_email)
60-
for (p = new_email; *p; p++)
61-
*p = tolower(*p);
6254

6355
if (old_email == NULL) {
6456
old_email = new_email;
@@ -68,13 +60,17 @@ static void add_mapping(struct string_list *map,
6860
if ((index = string_list_find_insert_index(map, old_email, 1)) < 0) {
6961
/* mailmap entry exists, invert index value */
7062
index = -1 - index;
63+
me = (struct mailmap_entry *)map->items[index].util;
7164
} else {
7265
/* create mailmap entry */
73-
struct string_list_item *item = string_list_insert_at_index(map, index, old_email);
74-
item->util = xcalloc(1, sizeof(struct mailmap_entry));
75-
((struct mailmap_entry *)item->util)->namemap.strdup_strings = 1;
66+
struct string_list_item *item;
67+
68+
item = string_list_insert_at_index(map, index, old_email);
69+
me = xcalloc(1, sizeof(struct mailmap_entry));
70+
me->namemap.strdup_strings = 1;
71+
me->namemap.cmp = strcasecmp;
72+
item->util = me;
7673
}
77-
me = (struct mailmap_entry *)map->items[index].util;
7874

7975
if (old_name == NULL) {
8076
debug_mm("mailmap: adding (simple) entry for %s at index %d\n", old_email, index);

t/t4203-mailmap.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ test_expect_success 'single-character name' '
256256
test_cmp expect actual
257257
'
258258

259-
test_expect_failure 'preserve canonical email case' '
259+
test_expect_success 'preserve canonical email case' '
260260
echo " 1 A U Thor <[email protected]>" >expect &&
261261
echo " 1 nick1 <[email protected]>" >>expect &&
262262
echo "<[email protected]> <[email protected]>" >.mailmap &&

0 commit comments

Comments
 (0)