aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authorChristian Muehlhaeuser <muesli@gmail.com>2019-07-23 20:50:39 +0200
committerzeripath <art27@cantab.net>2019-07-23 19:50:39 +0100
commit54d96c79b5b9f3d5d47aed59729ae779968fbecb (patch)
tree3d74fa2aecf3a9c5a23a1ec0c7e66fca270216aa /modules/git
parent2f75766532fbf30883c05e93ef01c19268216c45 (diff)
downloadgitea-54d96c79b5b9f3d5d47aed59729ae779968fbecb.tar.gz
gitea-54d96c79b5b9f3d5d47aed59729ae779968fbecb.zip
Removed unnecessary conversions (#7557)
No need to convert to the same type.
Diffstat (limited to 'modules/git')
-rw-r--r--modules/git/commit_info.go2
-rw-r--r--modules/git/notes.go4
-rw-r--r--modules/git/parse.go3
-rw-r--r--modules/git/repo_blame.go2
-rw-r--r--modules/git/repo_blob.go2
-rw-r--r--modules/git/repo_commit.go4
-rw-r--r--modules/git/repo_ref.go4
-rw-r--r--modules/git/repo_tree.go6
-rw-r--r--modules/git/tree.go2
-rw-r--r--modules/git/tree_blob.go3
10 files changed, 13 insertions, 19 deletions
diff --git a/modules/git/commit_info.go b/modules/git/commit_info.go
index 3fa80457ac..d8bf88a47c 100644
--- a/modules/git/commit_info.go
+++ b/modules/git/commit_info.go
@@ -25,7 +25,7 @@ func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCom
defer commitGraphFile.Close()
}
- c, err := commitNodeIndex.Get(plumbing.Hash(commit.ID))
+ c, err := commitNodeIndex.Get(commit.ID)
if err != nil {
return nil, nil, err
}
diff --git a/modules/git/notes.go b/modules/git/notes.go
index a62c558787..aea54ab202 100644
--- a/modules/git/notes.go
+++ b/modules/git/notes.go
@@ -6,8 +6,6 @@ package git
import (
"io/ioutil"
-
- "gopkg.in/src-d/go-git.v4/plumbing"
)
// NotesRef is the git ref where Gitea will look for git-notes data.
@@ -45,7 +43,7 @@ func GetNote(repo *Repository, commitID string, note *Note) error {
}
note.Message = d
- commit, err := repo.gogitRepo.CommitObject(plumbing.Hash(notes.ID))
+ commit, err := repo.gogitRepo.CommitObject(notes.ID)
if err != nil {
return err
}
diff --git a/modules/git/parse.go b/modules/git/parse.go
index 22861b1d2c..cbd48b9189 100644
--- a/modules/git/parse.go
+++ b/modules/git/parse.go
@@ -9,7 +9,6 @@ import (
"fmt"
"strconv"
- "gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/filemode"
"gopkg.in/src-d/go-git.v4/plumbing/object"
)
@@ -57,7 +56,7 @@ func parseTreeEntries(data []byte, ptree *Tree) ([]*TreeEntry, error) {
return nil, fmt.Errorf("Invalid ls-tree output: %v", err)
}
entry.ID = id
- entry.gogitTreeEntry.Hash = plumbing.Hash(id)
+ entry.gogitTreeEntry.Hash = id
pos += 41 // skip over sha and trailing space
end := pos + bytes.IndexByte(data[pos:], '\n')
diff --git a/modules/git/repo_blame.go b/modules/git/repo_blame.go
index 80ec50e472..5c023554f1 100644
--- a/modules/git/repo_blame.go
+++ b/modules/git/repo_blame.go
@@ -20,5 +20,5 @@ func (repo *Repository) LineBlame(revision, path, file string, line uint) (*Comm
if len(res) < 40 {
return nil, fmt.Errorf("invalid result of blame: %s", res)
}
- return repo.GetCommit(string(res[:40]))
+ return repo.GetCommit(res[:40])
}
diff --git a/modules/git/repo_blob.go b/modules/git/repo_blob.go
index db63491ce4..45ca604402 100644
--- a/modules/git/repo_blob.go
+++ b/modules/git/repo_blob.go
@@ -9,7 +9,7 @@ import (
)
func (repo *Repository) getBlob(id SHA1) (*Blob, error) {
- encodedObj, err := repo.gogitRepo.Storer.EncodedObject(plumbing.AnyObject, plumbing.Hash(id))
+ encodedObj, err := repo.gogitRepo.Storer.EncodedObject(plumbing.AnyObject, id)
if err != nil {
return nil, ErrNotExist{id.String(), ""}
}
diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go
index 8429a57039..733991612a 100644
--- a/modules/git/repo_commit.go
+++ b/modules/git/repo_commit.go
@@ -86,9 +86,9 @@ func convertPGPSignatureForTag(t *object.Tag) *CommitGPGSignature {
func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
var tagObject *object.Tag
- gogitCommit, err := repo.gogitRepo.CommitObject(plumbing.Hash(id))
+ gogitCommit, err := repo.gogitRepo.CommitObject(id)
if err == plumbing.ErrObjectNotFound {
- tagObject, err = repo.gogitRepo.TagObject(plumbing.Hash(id))
+ tagObject, err = repo.gogitRepo.TagObject(id)
if err == nil {
gogitCommit, err = repo.gogitRepo.CommitObject(tagObject.Target)
}
diff --git a/modules/git/repo_ref.go b/modules/git/repo_ref.go
index 95a6c2ae69..9044dbeadd 100644
--- a/modules/git/repo_ref.go
+++ b/modules/git/repo_ref.go
@@ -34,13 +34,13 @@ func (repo *Repository) GetRefsFiltered(pattern string) ([]*Reference, error) {
refType := string(ObjectCommit)
if ref.Name().IsTag() {
// tags can be of type `commit` (lightweight) or `tag` (annotated)
- if tagType, _ := repo.GetTagType(SHA1(ref.Hash())); err == nil {
+ if tagType, _ := repo.GetTagType(ref.Hash()); err == nil {
refType = tagType
}
}
r := &Reference{
Name: ref.Name().String(),
- Object: SHA1(ref.Hash()),
+ Object: ref.Hash(),
Type: refType,
repo: repo,
}
diff --git a/modules/git/repo_tree.go b/modules/git/repo_tree.go
index 7d32d3685c..ddc398d0b2 100644
--- a/modules/git/repo_tree.go
+++ b/modules/git/repo_tree.go
@@ -10,12 +10,10 @@ import (
"os"
"strings"
"time"
-
- "gopkg.in/src-d/go-git.v4/plumbing"
)
func (repo *Repository) getTree(id SHA1) (*Tree, error) {
- gogitTree, err := repo.gogitRepo.TreeObject(plumbing.Hash(id))
+ gogitTree, err := repo.gogitRepo.TreeObject(id)
if err != nil {
return nil, err
}
@@ -41,7 +39,7 @@ func (repo *Repository) GetTree(idStr string) (*Tree, error) {
return nil, err
}
resolvedID := id
- commitObject, err := repo.gogitRepo.CommitObject(plumbing.Hash(id))
+ commitObject, err := repo.gogitRepo.CommitObject(id)
if err == nil {
id = SHA1(commitObject.TreeHash)
}
diff --git a/modules/git/tree.go b/modules/git/tree.go
index 6ca893cb7b..58c4d8cad1 100644
--- a/modules/git/tree.go
+++ b/modules/git/tree.go
@@ -63,7 +63,7 @@ func (t *Tree) SubTree(rpath string) (*Tree, error) {
}
func (t *Tree) loadTreeObject() error {
- gogitTree, err := t.repo.gogitRepo.TreeObject(plumbing.Hash(t.ID))
+ gogitTree, err := t.repo.gogitRepo.TreeObject(t.ID)
if err != nil {
return err
}
diff --git a/modules/git/tree_blob.go b/modules/git/tree_blob.go
index eb8ddd0946..cdbe031a2c 100644
--- a/modules/git/tree_blob.go
+++ b/modules/git/tree_blob.go
@@ -9,7 +9,6 @@ import (
"path"
"strings"
- "gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/filemode"
"gopkg.in/src-d/go-git.v4/plumbing/object"
)
@@ -23,7 +22,7 @@ func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) {
gogitTreeEntry: &object.TreeEntry{
Name: "",
Mode: filemode.Dir,
- Hash: plumbing.Hash(t.ID),
+ Hash: t.ID,
},
}, nil
}