mailmap: debug: fix out-of-order fprintf() arguments
[gitweb.git] / mailmap.c
index 2a7b36628cb5623eb0ffb95bfb54e52a6dd300f4..051635472decd31aefcdeed327eb51a5e9d45497 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);
@@ -122,7 +118,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';
@@ -313,7 +309,7 @@ int map_user(struct string_list *map,
        struct mailmap_entry *me;
 
        debug_mm("map_user: map '%.*s' <%.*s>\n",
-                *name, *namelen, *emaillen, *email);
+                *namelen, *name, *emaillen, *email);
 
        item = lookup_prefix(map, *email, *emaillen);
        if (item != NULL) {