aboutsummaryrefslogtreecommitdiffstats
path: root/cshared
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-14 23:12:44 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-12-14 23:12:44 +0100
commit0af572dd21c0aa79d13745b633ee24ba6c4d6cf1 (patch)
tree49e81e74e82d84fd88b2fc1e4b0dc7c7bfe9c40f /cshared
parentdf0f38af83f972f026d7e14150f3d37b95f13484 (diff)
downloadgo-git-0af572dd21c0aa79d13745b633ee24ba6c4d6cf1.tar.gz
move plumbing from top level package to plumbing (#183)
* plumbing: rename Object -> EncodedObject. * plumbing/storer: rename ObjectStorer -> EncodedObjectStorer. * move difftree to plumbing/difftree. * move diff -> utils/diff * make Object/Tag/Blob/Tree/Commit/File depend on storer. * Object and its implementations now depend only on storer.EncodedObjectStorer, not git.Repository. * Tests are decoupled accordingly. * move Object/Commit/File/Tag/Tree to plumbing/object. * move Object/Commit/File/Tag/Tree to plumbing/object. * move checkClose to utils/ioutil. * move RevListObjects to plumbing/revlist.Objects. * move DiffTree to plumbing/difftree package. * rename files with plural nouns to singular * plumbing/object: add GetBlob/GetCommit/GetTag/GetTree.
Diffstat (limited to 'cshared')
-rw-r--r--cshared/blame_cshared.go8
-rw-r--r--cshared/commit_cshared.go43
-rw-r--r--cshared/file_cshared.go29
-rw-r--r--cshared/objects_cshared.go22
-rw-r--r--cshared/tag_cshared.go40
-rw-r--r--cshared/tree_cshared.go26
6 files changed, 85 insertions, 83 deletions
diff --git a/cshared/blame_cshared.go b/cshared/blame_cshared.go
index 8cb55e8..0f31cea 100644
--- a/cshared/blame_cshared.go
+++ b/cshared/blame_cshared.go
@@ -13,7 +13,7 @@ func c_Blame_get_Path(b uint64) *C.char {
if !ok {
return nil
}
- blame := obj.(*git.Blame)
+ blame := obj.(*git.BlameResult)
return C.CString(blame.Path)
}
@@ -23,7 +23,7 @@ func c_Blame_get_Rev(b uint64) *C.char {
if !ok {
return nil
}
- blame := obj.(*git.Blame)
+ blame := obj.(*git.BlameResult)
return CBytes(blame.Rev[:])
}
@@ -33,7 +33,7 @@ func c_Blame_get_Lines_len(b uint64) int {
if !ok {
return 0
}
- blame := obj.(*git.Blame)
+ blame := obj.(*git.BlameResult)
return len(blame.Lines)
}
@@ -43,7 +43,7 @@ func c_Blame_get_Lines_item(b uint64, i int) {
if !ok {
return
}
- blame := obj.(*git.Blame)
+ blame := obj.(*git.BlameResult)
line := blame.Lines[i]
_ = line
}
diff --git a/cshared/commit_cshared.go b/cshared/commit_cshared.go
index 756b0b2..cd46d7d 100644
--- a/cshared/commit_cshared.go
+++ b/cshared/commit_cshared.go
@@ -9,8 +9,9 @@ import (
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/object"
+ "gopkg.in/src-d/go-git.v4/plumbing/storer"
)
-import "gopkg.in/src-d/go-git.v4/plumbing/storer"
//export c_Commit_get_Hash
func c_Commit_get_Hash(c uint64) *C.char {
@@ -18,7 +19,7 @@ func c_Commit_get_Hash(c uint64) *C.char {
if !ok {
return nil
}
- commit := obj.(*git.Commit)
+ commit := obj.(*object.Commit)
return CBytes(commit.Hash[:])
}
@@ -28,7 +29,7 @@ func c_Commit_get_Author(c uint64) uint64 {
if !ok {
return IH
}
- commit := obj.(*git.Commit)
+ commit := obj.(*object.Commit)
author := &commit.Author
author_handle := RegisterObject(author)
return uint64(author_handle)
@@ -40,7 +41,7 @@ func c_Commit_get_Committer(c uint64) uint64 {
if !ok {
return IH
}
- commit := obj.(*git.Commit)
+ commit := obj.(*object.Commit)
committer := &commit.Committer
committer_handle := RegisterObject(committer)
return uint64(committer_handle)
@@ -52,7 +53,7 @@ func c_Commit_get_Message(c uint64) *C.char {
if !ok {
return nil
}
- commit := obj.(*git.Commit)
+ commit := obj.(*object.Commit)
return C.CString(commit.Message)
}
@@ -62,7 +63,7 @@ func c_Commit_Tree(c uint64) uint64 {
if !ok {
return IH
}
- commit := obj.(*git.Commit)
+ commit := obj.(*object.Commit)
tree, err := commit.Tree()
if err != nil {
return IH
@@ -78,7 +79,7 @@ func c_Commit_Parents(c uint64) uint64 {
if !ok {
return IH
}
- commit := obj.(*git.Commit)
+ commit := obj.(*object.Commit)
parents := commit.Parents()
parents_handle := RegisterObject(parents)
return uint64(parents_handle)
@@ -90,7 +91,7 @@ func c_Commit_NumParents(c uint64) int {
if !ok {
return -1
}
- commit := obj.(*git.Commit)
+ commit := obj.(*object.Commit)
return commit.NumParents()
}
@@ -100,7 +101,7 @@ func c_Commit_File(c uint64, path string) (uint64, int, *C.char) {
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- commit := obj.(*git.Commit)
+ commit := obj.(*object.Commit)
file, err := commit.File(CopyString(path))
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
@@ -120,18 +121,18 @@ func c_Commit_Type(c uint64) int8 {
if !ok {
return -1
}
- commit := obj.(*git.Commit)
+ commit := obj.(*object.Commit)
return int8(commit.Type())
}
//export c_Commit_Decode
func c_Commit_Decode(o uint64) (uint64, int, *C.char) {
- commit := git.Commit{}
+ commit := object.Commit{}
obj, ok := GetObject(Handle(o))
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- cobj := obj.(*plumbing.Object)
+ cobj := obj.(*plumbing.EncodedObject)
err := commit.Decode(*cobj)
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
@@ -145,7 +146,7 @@ func c_Commit_String(c uint64) *C.char {
if !ok {
return nil
}
- commit := obj.(*git.Commit)
+ commit := obj.(*object.Commit)
return C.CString(commit.String())
}
@@ -155,8 +156,8 @@ func c_Commit_References(c uint64, path string) (*C.char, int, int, *C.char) {
if !ok {
return nil, 0, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- commit := obj.(*git.Commit)
- refs, err := commit.References(CopyString(path))
+ commit := obj.(*object.Commit)
+ refs, err := git.References(commit, CopyString(path))
if err != nil {
return nil, 0, ErrorCodeInternal, C.CString(err.Error())
}
@@ -178,8 +179,8 @@ func c_Commit_Blame(c uint64, path string) (uint64, int, *C.char) {
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- commit := obj.(*git.Commit)
- blame, err := commit.Blame(CopyString(path))
+ commit := obj.(*object.Commit)
+ blame, err := git.Blame(commit, CopyString(path))
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
}
@@ -192,13 +193,13 @@ func c_NewCommitIter(r uint64, iter uint64) uint64 {
if !ok {
return IH
}
- repo := obj.(*git.Repository)
+ s := obj.(storer.EncodedObjectStorer)
obj, ok = GetObject(Handle(iter))
if !ok {
return IH
}
- obj_iter := obj.(*storer.ObjectIter)
- commit_iter := git.NewCommitIter(repo, *obj_iter)
+ obj_iter := obj.(storer.EncodedObjectIter)
+ commit_iter := object.NewCommitIter(s, obj_iter)
handle := RegisterObject(commit_iter)
return uint64(handle)
}
@@ -209,7 +210,7 @@ func c_CommitIter_Next(iter uint64) (uint64, int, *C.char) {
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- commitIter := obj.(*git.CommitIter)
+ commitIter := obj.(*object.CommitIter)
commit, err := commitIter.Next()
if err != nil {
if err == io.EOF {
diff --git a/cshared/file_cshared.go b/cshared/file_cshared.go
index 8ef6427..d9c95b0 100644
--- a/cshared/file_cshared.go
+++ b/cshared/file_cshared.go
@@ -5,8 +5,9 @@ import (
"io"
"io/ioutil"
- "gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/object"
+ "gopkg.in/src-d/go-git.v4/plumbing/storer"
)
//export c_File_get_Name
@@ -15,7 +16,7 @@ func c_File_get_Name(f uint64) *C.char {
if !ok {
return nil
}
- file := obj.(*git.File)
+ file := obj.(*object.File)
return C.CString(file.Name)
}
@@ -25,7 +26,7 @@ func c_File_get_Mode(f uint64) uint32 {
if !ok {
return 0
}
- file := obj.(*git.File)
+ file := obj.(*object.File)
return uint32(file.Mode)
}
@@ -35,7 +36,7 @@ func c_File_get_Hash(b uint64) *C.char {
if !ok {
return nil
}
- file := obj.(*git.File)
+ file := obj.(*object.File)
return CBytes(file.Hash[:])
}
@@ -45,7 +46,7 @@ func c_File_Size(b uint64) int64 {
if !ok {
return -1
}
- file := obj.(*git.File)
+ file := obj.(*object.File)
return file.Size
}
@@ -55,8 +56,8 @@ func c_File_Decode(o uint64) uint64 {
if !ok {
return IH
}
- cobj := obj.(*plumbing.Object)
- file := git.File{}
+ cobj := obj.(*plumbing.EncodedObject)
+ file := object.File{}
file.Decode(*cobj)
return uint64(RegisterObject(&file))
}
@@ -67,7 +68,7 @@ func c_File_Read(b uint64) (int, *C.char) {
if !ok {
return ErrorCodeNotFound, C.CString(MessageNotFound)
}
- file := obj.(*git.File)
+ file := obj.(*object.File)
reader, err := file.Reader()
if err != nil {
return ErrorCodeInternal, C.CString(err.Error())
@@ -86,7 +87,7 @@ func c_File_Type(c uint64) int8 {
if !ok {
return -1
}
- file := obj.(*git.File)
+ file := obj.(*object.File)
return int8(file.Type())
}
@@ -96,13 +97,13 @@ func c_NewFileIter(r uint64, t uint64) uint64 {
if !ok {
return IH
}
- repo := obj.(*git.Repository)
+ storer := obj.(storer.EncodedObjectStorer)
obj, ok = GetObject(Handle(t))
if !ok {
return IH
}
- tree := obj.(*git.Tree)
- iter := git.NewFileIter(repo, tree)
+ tree := obj.(*object.Tree)
+ iter := object.NewFileIter(storer, tree)
return uint64(RegisterObject(iter))
}
@@ -112,7 +113,7 @@ func c_FileIter_Next(i uint64) (uint64, int, *C.char) {
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- iter := obj.(*git.FileIter)
+ iter := obj.(*object.FileIter)
file, err := iter.Next()
if err != nil {
if err == io.EOF {
@@ -129,6 +130,6 @@ func c_FileIter_Close(i uint64) {
if !ok {
return
}
- iter := obj.(*git.FileIter)
+ iter := obj.(*object.FileIter)
iter.Close()
}
diff --git a/cshared/objects_cshared.go b/cshared/objects_cshared.go
index 54b9426..60bac40 100644
--- a/cshared/objects_cshared.go
+++ b/cshared/objects_cshared.go
@@ -6,8 +6,8 @@ import (
"io/ioutil"
"time"
- "gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/object"
)
//export c_Signature_Name
@@ -16,7 +16,7 @@ func c_Signature_Name(s uint64) *C.char {
if !ok {
return nil
}
- sign := obj.(*git.Signature)
+ sign := obj.(*object.Signature)
return C.CString(sign.Name)
}
@@ -26,7 +26,7 @@ func c_Signature_Email(s uint64) *C.char {
if !ok {
return nil
}
- sign := obj.(*git.Signature)
+ sign := obj.(*object.Signature)
return C.CString(sign.Email)
}
@@ -36,13 +36,13 @@ func c_Signature_When(s uint64) *C.char {
if !ok {
return nil
}
- sign := obj.(*git.Signature)
+ sign := obj.(*object.Signature)
return C.CString(sign.When.Format(time.RFC3339))
}
//export c_Signature_Decode
func c_Signature_Decode(b []byte) uint64 {
- sign := git.Signature{}
+ sign := object.Signature{}
sign.Decode(b)
return uint64(RegisterObject(&sign))
}
@@ -53,7 +53,7 @@ func c_Blob_get_Hash(b uint64) *C.char {
if !ok {
return nil
}
- blob := obj.(*git.Blob)
+ blob := obj.(*object.Blob)
return CBytes(blob.Hash[:])
}
@@ -63,7 +63,7 @@ func c_Blob_Size(b uint64) int64 {
if !ok {
return -1
}
- blob := obj.(*git.Blob)
+ blob := obj.(*object.Blob)
return blob.Size
}
@@ -73,8 +73,8 @@ func c_Blob_Decode(o uint64) uint64 {
if !ok {
return IH
}
- cobj := obj.(*plumbing.Object)
- blob := git.Blob{}
+ cobj := obj.(*plumbing.EncodedObject)
+ blob := object.Blob{}
blob.Decode(*cobj)
return uint64(RegisterObject(&blob))
}
@@ -85,7 +85,7 @@ func c_Blob_Read(b uint64) (int, *C.char) {
if !ok {
return ErrorCodeNotFound, C.CString(MessageNotFound)
}
- blob := obj.(*git.Blob)
+ blob := obj.(*object.Blob)
reader, err := blob.Reader()
if err != nil {
return ErrorCodeInternal, C.CString(err.Error())
@@ -104,6 +104,6 @@ func c_Blob_Type(c uint64) int8 {
if !ok {
return -1
}
- blob := obj.(*git.Blob)
+ blob := obj.(*object.Blob)
return int8(blob.Type())
}
diff --git a/cshared/tag_cshared.go b/cshared/tag_cshared.go
index dd0814a..860a1c6 100644
--- a/cshared/tag_cshared.go
+++ b/cshared/tag_cshared.go
@@ -5,17 +5,17 @@ import (
"C"
"io"
- "gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/object"
+ "gopkg.in/src-d/go-git.v4/plumbing/storer"
)
-import "gopkg.in/src-d/go-git.v4/plumbing/storer"
func c_Tag_get_Hash(t uint64) *C.char {
obj, ok := GetObject(Handle(t))
if !ok {
return nil
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
return CBytes(tag.Hash[:])
}
@@ -24,7 +24,7 @@ func c_Tag_get_Name(t uint64) *C.char {
if !ok {
return nil
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
return C.CString(tag.Name)
}
@@ -33,7 +33,7 @@ func c_Tag_get_Tagger(t uint64) uint64 {
if !ok {
return IH
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
return uint64(RegisterObject(&tag.Tagger))
}
@@ -42,7 +42,7 @@ func c_Tag_get_Message(t uint64) *C.char {
if !ok {
return nil
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
return C.CString(tag.Message)
}
@@ -51,7 +51,7 @@ func c_Tag_get_TargetType(t uint64) int8 {
if !ok {
return -1
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
return int8(tag.TargetType)
}
@@ -60,7 +60,7 @@ func c_Tag_get_Target(t uint64) *C.char {
if !ok {
return nil
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
return CBytes(tag.Target[:])
}
@@ -70,7 +70,7 @@ func c_Tag_Type(t uint64) int8 {
if !ok {
return -1
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
return int8(tag.Type())
}
@@ -80,8 +80,8 @@ func c_Tag_Decode(o uint64) (uint64, int, *C.char) {
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- cobj := obj.(*plumbing.Object)
- tag := git.Tag{}
+ cobj := obj.(*plumbing.EncodedObject)
+ tag := object.Tag{}
err := tag.Decode(*cobj)
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
@@ -95,7 +95,7 @@ func c_Tag_Commit(t uint64) (uint64, int, *C.char) {
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
commit, err := tag.Commit()
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
@@ -109,7 +109,7 @@ func c_Tag_Tree(t uint64) (uint64, int, *C.char) {
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
tree, err := tag.Tree()
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
@@ -123,7 +123,7 @@ func c_Tag_Blob(t uint64) (uint64, int, *C.char) {
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
blob, err := tag.Blob()
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
@@ -137,7 +137,7 @@ func c_Tag_Object(t uint64) (uint64, int, *C.char) {
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
object, err := tag.Object()
if err != nil {
return IH, ErrorCodeInternal, C.CString(err.Error())
@@ -151,7 +151,7 @@ func c_Tag_String(t uint64) *C.char {
if !ok {
return nil
}
- tag := obj.(*git.Tag)
+ tag := obj.(*object.Tag)
return C.CString(tag.String())
}
@@ -161,13 +161,13 @@ func c_NewTagIter(r uint64, i uint64) uint64 {
if !ok {
return IH
}
- repo := obj.(*git.Repository)
+ s := obj.(storer.EncodedObjectStorer)
obj, ok = GetObject(Handle(i))
if !ok {
return IH
}
- iter := obj.(*storer.ObjectIter)
- return uint64(RegisterObject(git.NewTagIter(repo, *iter)))
+ iter := obj.(*storer.EncodedObjectIter)
+ return uint64(RegisterObject(object.NewTagIter(s, *iter)))
}
//export c_TagIter_Next
@@ -176,7 +176,7 @@ func c_TagIter_Next(i uint64) (uint64, int, *C.char) {
if !ok {
return IH, ErrorCodeNotFound, C.CString(MessageNotFound)
}
- tagiter := obj.(*git.TagIter)
+ tagiter := obj.(*object.TagIter)
tag, err := tagiter.Next()
if err != nil {
if err == io.EOF {
diff --git a/cshared/tree_cshared.go b/cshared/tree_cshared.go
index 8533f60..12e360e 100644
--- a/cshared/tree_cshared.go
+++ b/cshared/tree_cshared.go
@@ -21,7 +21,7 @@ func c_Tree_get_Entries_len(t uint64) int {
if !ok {
return 0
}
- tree := obj.(*git.Tree)
+ tree := obj.(*object.Tree)
return len(tree.Entries)
}
@@ -33,7 +33,7 @@ func c_Tree_get_Entries_item(t uint64, index int) (*_Ctype_char, uint32, *_Ctype
if !ok {
return nil, 0, nil
}
- tree := obj.(*git.Tree)
+ tree := obj.(*object.Tree)
item := tree.Entries[index]
return _Cfunc_CString(item.Name), uint32(item.Mode), CBytes(item.Hash[:])
}
@@ -46,7 +46,7 @@ func c_Tree_get_Hash(t uint64) *_Ctype_char {
if !ok {
return nil
}
- tree := obj.(*git.Tree)
+ tree := obj.(*object.Tree)
return CBytes(tree.Hash[:])
}
@@ -58,7 +58,7 @@ func c_Tree_File(t uint64, path string) (uint64, int, *_Ctype_char) {
if !ok {
return IH, ErrorCodeNotFound, _Cfunc_CString(MessageNotFound)
}
- tree := obj.(*git.Tree)
+ tree := obj.(*object.Tree)
file, err := tree.File(CopyString(path))
if err != nil {
return IH, ErrorCodeInternal, _Cfunc_CString(err.Error())
@@ -74,7 +74,7 @@ func c_Tree_Type(t uint64) int8 {
if !ok {
return -1
}
- tree := obj.(*git.Tree)
+ tree := obj.(*object.Tree)
return int8(tree.Type())
}
@@ -86,7 +86,7 @@ func c_Tree_Files(t uint64) uint64 {
if !ok {
return IH
}
- tree := obj.(*git.Tree)
+ tree := obj.(*object.Tree)
iter := tree.Files()
return uint64(RegisterObject(iter))
}
@@ -99,8 +99,8 @@ func c_Tree_Decode(o uint64) (uint64, int, *_Ctype_char) {
if !ok {
return IH, ErrorCodeNotFound, _Cfunc_CString(MessageNotFound)
}
- cobj := obj.(*plumbing.Object)
- tree := git.Tree{}
+ cobj := obj.(*plumbing.EncodedObject)
+ tree := object.Tree{}
err := tree.Decode(*cobj)
if err != nil {
return IH, ErrorCodeInternal, _Cfunc_CString(err.Error())
@@ -121,8 +121,8 @@ func c_NewTreeWalker(r uint64, t uint64) uint64 {
if !ok {
return IH
}
- tree := obj.(*git.Tree)
- walker := git.NewTreeIter(repo, tree)
+ tree := obj.(*object.Tree)
+ walker := object.NewTreeIter(repo, tree)
return uint64(RegisterObject(walker))
}
@@ -134,7 +134,7 @@ func c_TreeWalker_Next(tw uint64) (*_Ctype_char, *_Ctype_char, uint32, *_Ctype_c
if !ok {
return nil, nil, 0, nil, ErrorCodeNotFound, _Cfunc_CString(MessageNotFound)
}
- walker := obj.(*git.TreeIter)
+ walker := obj.(*object.TreeIter)
name, entry, err := walker.Next()
if err != nil {
return nil, nil, 0, nil, ErrorCodeInternal, _Cfunc_CString(err.Error())
@@ -151,7 +151,7 @@ func c_TreeWalker_Tree(tw uint64) uint64 {
if !ok {
return IH
}
- walker := obj.(*git.TreeIter)
+ walker := obj.(*object.TreeIter)
return uint64(RegisterObject(walker.Tree()))
}
@@ -163,7 +163,7 @@ func c_TreeWalker_Close(tw uint64) {
if !ok {
return
}
- walker := obj.(*git.TreeIter)
+ walker := obj.(*object.TreeIter)
walker.Close()
}
*/