diff --git a/README.md b/README.md
index 25c7eb89d7..eb2e7ba990 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
 
 ![](public/img/gogs-large-resize.png)
 
-##### Current version: 0.7.39 Beta
+##### Current version: 0.7.40 Beta
 
 | Web | UI  | Preview  |
 |:-------------:|:-------:|:-------:|
diff --git a/gogs.go b/gogs.go
index 21f9bf9c91..305e6dd183 100644
--- a/gogs.go
+++ b/gogs.go
@@ -18,7 +18,7 @@ import (
 	"github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.7.39.1210 Beta"
+const APP_VER = "0.7.40.1210 Beta"
 
 func init() {
 	runtime.GOMAXPROCS(runtime.NumCPU())
diff --git a/models/action.go b/models/action.go
index 2c8eed85f2..89003214dd 100644
--- a/models/action.go
+++ b/models/action.go
@@ -440,10 +440,6 @@ func CommitRepoAction(
 			isNewBranch = true
 		}
 
-		// NOTE: limit to detect latest 100 commits.
-		if len(commit.Commits) > 100 {
-			commit.Commits = commit.Commits[len(commit.Commits)-100:]
-		}
 		if err = updateIssuesCommit(u, repo, repoUserName, repoName, commit.Commits); err != nil {
 			log.Error(4, "updateIssuesCommit: %v", err)
 		}
diff --git a/models/update.go b/models/update.go
index 9878f04a07..0c4d342d01 100644
--- a/models/update.go
+++ b/models/update.go
@@ -10,7 +10,7 @@ import (
 	"os/exec"
 	"strings"
 
-	"github.com/gogits/git-shell"
+	git "github.com/gogits/git-shell"
 
 	"github.com/gogits/gogs/modules/log"
 )
@@ -135,7 +135,7 @@ func Update(refName, oldCommitID, newCommitID, userName, repoUserName, repoName
 	// Push new branch.
 	var l *list.List
 	if isNew {
-		l, err = newCommit.CommitsBefore()
+		l, err = newCommit.CommitsBeforeLimit(10)
 		if err != nil {
 			return fmt.Errorf("CommitsBefore: %v", err)
 		}
diff --git a/models/user.go b/models/user.go
index 2806ef64ed..8993d7de3c 100644
--- a/models/user.go
+++ b/models/user.go
@@ -133,6 +133,9 @@ func (u *User) RepoCreationNum() int {
 
 func (u *User) CanCreateRepo() bool {
 	if u.MaxRepoCreation <= -1 {
+		if setting.Repository.MaxCreationLimit == -1 {
+			return true
+		}
 		return u.NumRepos < setting.Repository.MaxCreationLimit
 	}
 	return u.NumRepos < u.MaxRepoCreation
diff --git a/templates/.VERSION b/templates/.VERSION
index 370ba63b8d..b91cc6bc2d 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.7.39.1210 Beta
\ No newline at end of file
+0.7.40.1210 Beta
\ No newline at end of file