[PATCH 2/3] shortlog: read mailmap from ./.mailmap again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



While at it, remove the linux specific mailmap into
contrib/mailmap.linux.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@xxxxxx>
---
 builtin-shortlog.c    |   81 +++++++++++++++++++++++-------------------------
 contrib/mailmap.linux |   40 ++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 42 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 26212b0..afc9456 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -22,48 +22,40 @@ static int compare_by_number(const void
 		return +1;
 }
 
-static struct path_list_item mailmap_list[] = {
-	{ "R.Marek@xxxxxxxxxx", (void*)"Rudolf Marek" },
-	{ "Ralf.Wildenhues@xxxxxx", (void*)"Ralf Wildenhues" },
-	{ "aherrman@xxxxxxxxxx", (void*)"Andreas Herrmann" },
-	{ "akpm@xxxxxxxx", (void*)"Andrew Morton" },
-	{ "andrew.vasquez@xxxxxxxxxx", (void*)"Andrew Vasquez" },
-	{ "aquynh@xxxxxxxxx", (void*)"Nguyen Anh Quynh" },
-	{ "axboe@xxxxxxx", (void*)"Jens Axboe" },
-	{ "blaisorblade@xxxxxxxx", (void*)"Paolo 'Blaisorblade' Giarrusso" },
-	{ "bunk@xxxxxxxxx", (void*)"Adrian Bunk" },
-	{ "domen@xxxxxxxxxxxx", (void*)"Domen Puncer" },
-	{ "dougg@xxxxxxxxxx", (void*)"Douglas Gilbert" },
-	{ "dwmw2@xxxxxxxxxxxxxxxxxxxxxxx", (void*)"David Woodhouse" },
-	{ "ecashin@xxxxxxxxxx", (void*)"Ed L Cashin" },
-	{ "felix@xxxxxxxxxxxx", (void*)"Felix Moeller" },
-	{ "fzago@xxxxxxxxxxxxxxxxxxxxx", (void*)"Frank Zago" },
-	{ "gregkh@xxxxxxx", (void*)"Greg Kroah-Hartman" },
-	{ "hch@xxxxxx", (void*)"Christoph Hellwig" },
-	{ "htejun@xxxxxxxxx", (void*)"Tejun Heo" },
-	{ "jejb@mulgrave.(none)", (void*)"James Bottomley" },
-	{ "jejb@xxxxxxxxxxxxxxxxxxxxxxx", (void*)"James Bottomley" },
-	{ "jgarzik@xxxxxxxxxxxxxx", (void*)"Jeff Garzik" },
-	{ "johnpol@xxxxxxxxxxx", (void*)"Evgeniy Polyakov" },
-	{ "kay.sievers@xxxxxxxx", (void*)"Kay Sievers" },
-	{ "minyard@xxxxxxx", (void*)"Corey Minyard" },
-	{ "mshah@xxxxxxxx", (void*)"Mitesh shah" },
-	{ "pj@xxxxxxxxxxx", (void*)"Peter A Jonsson" },
-	{ "rmps@xxxxxxxxxxxxxxx", (void*)"Rui Saraiva" },
-	{ "santtu.hyrkko@xxxxxxxxx", (void*)"Santtu Hyrkk,Av(B" },
-	{ "simon@xxxxxxxxxxxxxxxxx", (void*)"Simon Kelley" },
-	{ "ssant@xxxxxxxxxx", (void*)"Sachin P Sant" },
-	{ "terra@xxxxxxxxx", (void*)"Morten Welinder" },
-	{ "tony.luck@xxxxxxxxx", (void*)"Tony Luck" },
-	{ "welinder@xxxxxxxxxxxxxxxxxx", (void*)"Morten Welinder" },
-	{ "welinder@xxxxxxxxxxxxxxxxx", (void*)"Morten Welinder" },
-	{ "welinder@xxxxxxxxx", (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 **
 		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 **
 
 	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
index 0000000..83927c9
--- /dev/null
+++ b/contrib/mailmap.linux
@@ -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@xxxxxxxxx>
+Andreas Herrmann <aherrman@xxxxxxxxxx>
+Andrew Morton <akpm@xxxxxxxx>
+Andrew Vasquez <andrew.vasquez@xxxxxxxxxx>
+Christoph Hellwig <hch@xxxxxx>
+Corey Minyard <minyard@xxxxxxx>
+David Woodhouse <dwmw2@xxxxxxxxxxxxxxxxxxxxxxx>
+Domen Puncer <domen@xxxxxxxxxxxx>
+Douglas Gilbert <dougg@xxxxxxxxxx>
+Ed L Cashin <ecashin@xxxxxxxxxx>
+Evgeniy Polyakov <johnpol@xxxxxxxxxxx>
+Felix Moeller <felix@xxxxxxxxxxxx>
+Frank Zago <fzago@xxxxxxxxxxxxxxxxxxxxx>
+Greg Kroah-Hartman <gregkh@xxxxxxx>
+James Bottomley <jejb@mulgrave.(none)>
+James Bottomley <jejb@xxxxxxxxxxxxxxxxxxxxxxx>
+Jeff Garzik <jgarzik@xxxxxxxxxxxxxx>
+Jens Axboe <axboe@xxxxxxx>
+Kay Sievers <kay.sievers@xxxxxxxx>
+Mitesh shah <mshah@xxxxxxxx>
+Morten Welinder <terra@xxxxxxxxx>
+Morten Welinder <welinder@xxxxxxxxxxxxxxxxxx>
+Morten Welinder <welinder@xxxxxxxxxxxxxxxxx>
+Morten Welinder <welinder@xxxxxxxxx>
+Nguyen Anh Quynh <aquynh@xxxxxxxxx>
+Paolo 'Blaisorblade' Giarrusso <blaisorblade@xxxxxxxx>
+Peter A Jonsson <pj@xxxxxxxxxxx>
+Ralf Wildenhues <Ralf.Wildenhues@xxxxxx>
+Rudolf Marek <R.Marek@xxxxxxxxxx>
+Rui Saraiva <rmps@xxxxxxxxxxxxxxx>
+Sachin P Sant <ssant@xxxxxxxxxx>
+Santtu Hyrkk,Av(B <santtu.hyrkko@xxxxxxxxx>
+Simon Kelley <simon@xxxxxxxxxxxxxxxxx>
+Tejun Heo <htejun@xxxxxxxxx>
+Tony Luck <tony.luck@xxxxxxxxx>
-- 
1.4.4.GIT

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]