aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/difftree/change_adaptor.go
diff options
context:
space:
mode:
authorAntonio Jesus Navarro Perez <antonio@sourced.tech>2017-02-22 15:49:37 +0100
committerAntonio Jesus Navarro Perez <antonio@sourced.tech>2017-02-24 11:08:14 +0100
commitaffc06dec90529073b5a3b76291b953232f034d9 (patch)
tree4300a62bfc3957d51183321254dae3e9d4a314c9 /plumbing/difftree/change_adaptor.go
parentf93e5712a86b96370673a02fa7ffbe5e0aec0c66 (diff)
downloadgo-git-affc06dec90529073b5a3b76291b953232f034d9.tar.gz
plumbing/object: move difftree to object package
- To avoid ciclic dependency errors, we move all the difftree files to object package. - Added Diff method to Tree object.
Diffstat (limited to 'plumbing/difftree/change_adaptor.go')
-rw-r--r--plumbing/difftree/change_adaptor.go61
1 files changed, 0 insertions, 61 deletions
diff --git a/plumbing/difftree/change_adaptor.go b/plumbing/difftree/change_adaptor.go
deleted file mode 100644
index edc20b3..0000000
--- a/plumbing/difftree/change_adaptor.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package difftree
-
-// The folowing functions transform changes types form the merkletrie
-// package to changes types from this package.
-
-import (
- "fmt"
-
- "srcd.works/go-git.v4/plumbing/object"
- "srcd.works/go-git.v4/utils/merkletrie"
- "srcd.works/go-git.v4/utils/merkletrie/noder"
-)
-
-func newChange(c merkletrie.Change) (*Change, error) {
- ret := &Change{}
-
- var err error
- if ret.From, err = newChangeEntry(c.From); err != nil {
- return nil, fmt.Errorf("From field: ", err)
- }
-
- if ret.To, err = newChangeEntry(c.To); err != nil {
- return nil, fmt.Errorf("To field: ", err)
- }
-
- return ret, nil
-}
-
-func newChangeEntry(p noder.Path) (ChangeEntry, error) {
- if p == nil {
- return empty, nil
- }
-
- asTreeNoder, ok := p.Last().(*treeNoder)
- if !ok {
- return ChangeEntry{}, fmt.Errorf("cannot transform non-TreeNoders")
- }
-
- return ChangeEntry{
- Name: p.String(),
- Tree: asTreeNoder.parent,
- TreeEntry: object.TreeEntry{
- Name: asTreeNoder.name,
- Mode: asTreeNoder.mode,
- Hash: asTreeNoder.hash,
- },
- }, nil
-}
-
-func newChanges(src merkletrie.Changes) (Changes, error) {
- ret := make(Changes, len(src))
- var err error
- for i, e := range src {
- ret[i], err = newChange(e)
- if err != nil {
- return nil, fmt.Errorf("change #%d: %s", err)
- }
- }
-
- return ret, nil
-}