From 0d9c41be7d7d4ae1d2a28931be5565c8f6d3f792 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 16 Sep 2014 10:10:33 -0400 Subject: Work on #476 --- modules/git/repo_commit.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'modules/git/repo_commit.go') diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index eebe3dd0e0..c9258927bb 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -137,6 +137,14 @@ func (repo *Repository) GetCommit(commitId string) (*Commit, error) { } func (repo *Repository) commitsCount(id sha1) (int, error) { + if gitVer.Compare(MustParseVersion("1.8.0")) == -1 { + stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", "--pretty=format:''", id.String()) + if err != nil { + return 0, errors.New(string(stderr)) + } + return len(bytes.Split(stdout, []byte("\n"))), nil + } + stdout, stderr, err := com.ExecCmdDir(repo.Path, "git", "rev-list", "--count", id.String()) if err != nil { return 0, errors.New(stderr) -- cgit v1.2.3