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 <gitster@pobox.com> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jul 15, 2013 at 02:54 UTC
97e751be7928d17c177b2fe65fb9bacf6ee35643
2 files changed
+9
-13
mailmap.c
+8
-12
@@ -51,14 +51,6 @@ static void add_mapping(struct string_list *map,
51
{
52
struct mailmap_entry *me;
53
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);
54
55
if (old_email == NULL) {
56
old_email = new_email;
@@ -68,13 +60,17 @@ static void add_mapping(struct string_list *map,
60
if ((index = string_list_find_insert_index(map, old_email, 1)) < 0) {
61
/* mailmap entry exists, invert index value */
62
index = -1 - index;
63
+ me = (struct mailmap_entry *)map->items[index].util;
64
} else {
65
/* 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;
73
}
77
- me = (struct mailmap_entry *)map->items[index].util;
74
75
if (old_name == NULL) {
76
debug_mm("mailmap: adding (simple) entry for %s at index %d\n", old_email, index);
t/t4203-mailmap.sh
+1
-1
@@ -256,7 +256,7 @@ test_expect_success 'single-character name' '
256
test_cmp expect actual
257
'
258
259
-test_expect_failure 'preserve canonical email case' '
259
+test_expect_success 'preserve canonical email case' '
260
echo " 1 A U Thor <AUTHOR@example.com>" >expect &&
261
echo " 1 nick1 <bugs@company.xx>" >>expect &&
262
echo "<AUTHOR@example.com> <author@example.com>" >.mailmap &&