summaryrefslogtreecommitdiffstats
path: root/modules/git/repo_commit.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-05-10 02:27:03 +0100
committerGitHub <noreply@github.com>2021-05-10 03:27:03 +0200
commit270aab429ef025df9a0b9bf9e3982729ae8df449 (patch)
tree215550ee5938876d4caf8516777d6f4bcaa91b40 /modules/git/repo_commit.go
parent038e1db4dfc7a7fc0a8675f66f6be9a3dd5f10c2 (diff)
downloadgitea-270aab429ef025df9a0b9bf9e3982729ae8df449.tar.gz
gitea-270aab429ef025df9a0b9bf9e3982729ae8df449.zip
On open repository open common cat file batch and batch-check (#15667)
Use common git cat-file --batch and git cat-file --batch-check to significantly reduce calls to git. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git/repo_commit.go')
-rw-r--r--modules/git/repo_commit.go21
1 files changed, 0 insertions, 21 deletions
diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go
index 5e2db34fd1..664a7445dd 100644
--- a/modules/git/repo_commit.go
+++ b/modules/git/repo_commit.go
@@ -24,27 +24,6 @@ func (repo *Repository) GetTagCommitID(name string) (string, error) {
return repo.GetRefCommitID(TagPrefix + name)
}
-// ConvertToSHA1 returns a Hash object from a potential ID string
-func (repo *Repository) ConvertToSHA1(commitID string) (SHA1, error) {
- if len(commitID) == 40 {
- sha1, err := NewIDFromString(commitID)
- if err == nil {
- return sha1, nil
- }
- }
-
- actualCommitID, err := NewCommand("rev-parse", "--verify", commitID).RunInDir(repo.Path)
- if err != nil {
- if strings.Contains(err.Error(), "unknown revision or path") ||
- strings.Contains(err.Error(), "fatal: Needed a single revision") {
- return SHA1{}, ErrNotExist{commitID, ""}
- }
- return SHA1{}, err
- }
-
- return NewIDFromString(actualCommitID)
-}
-
// GetCommit returns commit object of by ID string.
func (repo *Repository) GetCommit(commitID string) (*Commit, error) {
id, err := repo.ConvertToSHA1(commitID)