mailmap: do not downcase mailmap entries
authorJunio C Hamano <gitster@pobox.com>
Mon, 15 Jul 2013 06:54:08 +0000 (02:54 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Jul 2013 15:17:20 +0000 (08:17 -0700)
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>
mailmap.c
t/t4203-mailmap.sh
index 418081e6130885780249e7daef1a3e3a86181d58..a7e92db3d66b23deae11eb546f80588b6487cf1a 100644 (file)
--- 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);
index ffe6a11ac09105e945f43575060b520c65627d60..c32df80f1435faa73351bce867196b2ceede4ff5 100755 (executable)
@@ -256,7 +256,7 @@ test_expect_success 'single-character name' '
        test_cmp expect actual
 '
 
-test_expect_failure 'preserve canonical email case' '
+test_expect_success 'preserve canonical email case' '
        echo "     1    A U Thor <AUTHOR@example.com>" >expect &&
        echo "     1    nick1 <bugs@company.xx>" >>expect &&
        echo "<AUTHOR@example.com> <author@example.com>" >.mailmap &&