From bd55b78775f8dd04448d30e32f175918ee2b702e Mon Sep 17 00:00:00 2001
From: Unknwon <joe2010xtmf@163.com>
Date: Tue, 23 Sep 2014 23:18:14 -0400
Subject: [PATCH] Page: Commits and fix #249

---
 models/user.go | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/models/user.go b/models/user.go
index c09a77265f7a..49f8387d7934 100644
--- a/models/user.go
+++ b/models/user.go
@@ -522,15 +522,21 @@ type UserCommit struct {
 
 // ValidCommitsWithEmails checks if authors' e-mails of commits are correcponding to users.
 func ValidCommitsWithEmails(oldCommits *list.List) *list.List {
+	emails := map[string]string{}
 	newCommits := list.New()
 	e := oldCommits.Front()
 	for e != nil {
 		c := e.Value.(*git.Commit)
 
 		uname := ""
-		u, err := GetUserByEmail(c.Author.Email)
-		if err == nil {
-			uname = u.Name
+		if v, ok := emails[c.Author.Email]; !ok {
+			u, err := GetUserByEmail(c.Author.Email)
+			if err == nil {
+				uname = u.Name
+			}
+			emails[c.Author.Email] = uname
+		} else {
+			uname = v
 		}
 
 		newCommits.PushBack(UserCommit{