shortlog: read mailmap from ./.mailmap again
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>
Sun, 19 Nov 2006 16:28:51 +0000 (17:28 +0100)
committerJunio C Hamano <junkio@cox.net>
Mon, 20 Nov 2006 06:59:05 +0000 (22:59 -0800)
While at it, remove the linux specific mailmap into
contrib/mailmap.linux.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-shortlog.c
contrib/mailmap.linux [new file with mode: 0644]
index 26212b009c6b1bb1a17dacc174d2e59d0dc54ef1..afc945663d03ea30691ccc7967d407b3aa173fae 100644 (file)
@@ -22,48 +22,40 @@ static int compare_by_number(const void *a1, const void *a2)
                return +1;
 }
 
-static struct path_list_item mailmap_list[] = {
-       { "R.Marek@sh.cvut.cz", (void*)"Rudolf Marek" },
-       { "Ralf.Wildenhues@gmx.de", (void*)"Ralf Wildenhues" },
-       { "aherrman@de.ibm.com", (void*)"Andreas Herrmann" },
-       { "akpm@osdl.org", (void*)"Andrew Morton" },
-       { "andrew.vasquez@qlogic.com", (void*)"Andrew Vasquez" },
-       { "aquynh@gmail.com", (void*)"Nguyen Anh Quynh" },
-       { "axboe@suse.de", (void*)"Jens Axboe" },
-       { "blaisorblade@yahoo.it", (void*)"Paolo 'Blaisorblade' Giarrusso" },
-       { "bunk@stusta.de", (void*)"Adrian Bunk" },
-       { "domen@coderock.org", (void*)"Domen Puncer" },
-       { "dougg@torque.net", (void*)"Douglas Gilbert" },
-       { "dwmw2@shinybook.infradead.org", (void*)"David Woodhouse" },
-       { "ecashin@coraid.com", (void*)"Ed L Cashin" },
-       { "felix@derklecks.de", (void*)"Felix Moeller" },
-       { "fzago@systemfabricworks.com", (void*)"Frank Zago" },
-       { "gregkh@suse.de", (void*)"Greg Kroah-Hartman" },
-       { "hch@lst.de", (void*)"Christoph Hellwig" },
-       { "htejun@gmail.com", (void*)"Tejun Heo" },
-       { "jejb@mulgrave.(none)", (void*)"James Bottomley" },
-       { "jejb@titanic.il.steeleye.com", (void*)"James Bottomley" },
-       { "jgarzik@pretzel.yyz.us", (void*)"Jeff Garzik" },
-       { "johnpol@2ka.mipt.ru", (void*)"Evgeniy Polyakov" },
-       { "kay.sievers@vrfy.org", (void*)"Kay Sievers" },
-       { "minyard@acm.org", (void*)"Corey Minyard" },
-       { "mshah@teja.com", (void*)"Mitesh shah" },
-       { "pj@ludd.ltu.se", (void*)"Peter A Jonsson" },
-       { "rmps@joel.ist.utl.pt", (void*)"Rui Saraiva" },
-       { "santtu.hyrkko@gmail.com", (void*)"Santtu Hyrkk\e,Av\e(B" },
-       { "simon@thekelleys.org.uk", (void*)"Simon Kelley" },
-       { "ssant@in.ibm.com", (void*)"Sachin P Sant" },
-       { "terra@gnome.org", (void*)"Morten Welinder" },
-       { "tony.luck@intel.com", (void*)"Tony Luck" },
-       { "welinder@anemone.rentec.com", (void*)"Morten Welinder" },
-       { "welinder@darter.rentec.com", (void*)"Morten Welinder" },
-       { "welinder@troll.com", (void*)"Morten Welinder" }
-};
-
-static struct path_list mailmap = {
-       mailmap_list,
-       sizeof(mailmap_list) / sizeof(struct path_list_item), 0, 0
-};
+static struct path_list mailmap = {NULL, 0, 0, 0};
+
+static int read_mailmap(const char *filename)
+{
+       char buffer[1024];
+       FILE *f = fopen(filename, "r");
+
+       if (f == NULL)
+               return 1;
+       while (fgets(buffer, sizeof(buffer), f) != NULL) {
+               char *end_of_name, *left_bracket, *right_bracket;
+               char *name, *email;
+               if (buffer[0] == '#')
+                       continue;
+               if ((left_bracket = strchr(buffer, '<')) == NULL)
+                       continue;
+               if ((right_bracket = strchr(left_bracket + 1, '>')) == NULL)
+                       continue;
+               if (right_bracket == left_bracket + 1)
+                       continue;
+               for (end_of_name = left_bracket; end_of_name != buffer
+                               && isspace(end_of_name[-1]); end_of_name--)
+                       /* keep on looking */
+               if (end_of_name == buffer)
+                       continue;
+               name = xmalloc(end_of_name - buffer + 1);
+               strlcpy(name, buffer, end_of_name - buffer + 1);
+               email = xmalloc(right_bracket - left_bracket);
+               strlcpy(email, left_bracket + 1, right_bracket - left_bracket);
+               path_list_insert(email, &mailmap)->util = name;
+       }
+       fclose(f);
+       return 0;
+}
 
 static int map_email(char *email, char *name, int maxlen)
 {
@@ -269,6 +261,9 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
                argc--;
        }
 
+       if (!access(".mailmap", R_OK))
+               read_mailmap(".mailmap");
+
        if (rev.pending.nr == 1)
                die ("Need a range!");
        else if (rev.pending.nr == 0)
@@ -298,6 +293,8 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)
 
        list.strdup_paths = 1;
        path_list_clear(&list, 1);
+       mailmap.strdup_paths = 1;
+       path_list_clear(&mailmap, 1);
 
        return 0;
 }
diff --git a/contrib/mailmap.linux b/contrib/mailmap.linux
new file mode 100644 (file)
index 0000000..83927c9
--- /dev/null
@@ -0,0 +1,40 @@
+#
+# Even with git, we don't always have name translations.
+# So have an email->real name table to translate the
+# (hopefully few) missing names
+#
+Adrian Bunk <bunk@stusta.de>
+Andreas Herrmann <aherrman@de.ibm.com>
+Andrew Morton <akpm@osdl.org>
+Andrew Vasquez <andrew.vasquez@qlogic.com>
+Christoph Hellwig <hch@lst.de>
+Corey Minyard <minyard@acm.org>
+David Woodhouse <dwmw2@shinybook.infradead.org>
+Domen Puncer <domen@coderock.org>
+Douglas Gilbert <dougg@torque.net>
+Ed L Cashin <ecashin@coraid.com>
+Evgeniy Polyakov <johnpol@2ka.mipt.ru>
+Felix Moeller <felix@derklecks.de>
+Frank Zago <fzago@systemfabricworks.com>
+Greg Kroah-Hartman <gregkh@suse.de>
+James Bottomley <jejb@mulgrave.(none)>
+James Bottomley <jejb@titanic.il.steeleye.com>
+Jeff Garzik <jgarzik@pretzel.yyz.us>
+Jens Axboe <axboe@suse.de>
+Kay Sievers <kay.sievers@vrfy.org>
+Mitesh shah <mshah@teja.com>
+Morten Welinder <terra@gnome.org>
+Morten Welinder <welinder@anemone.rentec.com>
+Morten Welinder <welinder@darter.rentec.com>
+Morten Welinder <welinder@troll.com>
+Nguyen Anh Quynh <aquynh@gmail.com>
+Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
+Peter A Jonsson <pj@ludd.ltu.se>
+Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+Rudolf Marek <R.Marek@sh.cvut.cz>
+Rui Saraiva <rmps@joel.ist.utl.pt>
+Sachin P Sant <ssant@in.ibm.com>
+Santtu Hyrkk\e,Av\e(B <santtu.hyrkko@gmail.com>
+Simon Kelley <simon@thekelleys.org.uk>
+Tejun Heo <htejun@gmail.com>
+Tony Luck <tony.luck@intel.com>