aboutsummaryrefslogtreecommitdiffstats
path: root/difftree/internal/merkletrie/node.go
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 /difftree/internal/merkletrie/node.go
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 'difftree/internal/merkletrie/node.go')
-rw-r--r--difftree/internal/merkletrie/node.go65
1 files changed, 0 insertions, 65 deletions
diff --git a/difftree/internal/merkletrie/node.go b/difftree/internal/merkletrie/node.go
deleted file mode 100644
index 99be5b8..0000000
--- a/difftree/internal/merkletrie/node.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package merkletrie
-
-import (
- "sort"
- "strings"
-)
-
-// A node is a Noder implementation for testing purposes: It is easier
-// to create test trees using nodes than using real git tree objects.
-type node struct {
- hash []byte
- key string
- children []*node
-}
-
-// newNode returns a new Node with the given hash, key and children
-// (children can be specified in any order).
-func newNode(hash []byte, key string, children []*node) *node {
- sort.Sort(reverseAlphabeticallyByKey(children))
-
- return &node{
- hash: hash,
- key: key,
- children: children,
- }
-}
-
-// Hash returns the hash of the node.
-func (n *node) Hash() []byte {
- return n.hash
-}
-
-// Key returns the key of the node.
-func (n *node) Key() string {
- return n.key
-}
-
-// NumChildren returns the number of children.
-func (n *node) NumChildren() int {
- return len(n.children)
-}
-
-// Children returns the node's children in reverse key alphabetical
-// order.
-func (n *node) Children() []Noder {
- ret := make([]Noder, n.NumChildren())
- for i := range n.children {
- ret[i] = n.children[i]
- }
- return ret
-}
-
-type reverseAlphabeticallyByKey []*node
-
-func (a reverseAlphabeticallyByKey) Len() int {
- return len(a)
-}
-
-func (a reverseAlphabeticallyByKey) Swap(i, j int) {
- a[i], a[j] = a[j], a[i]
-}
-
-func (a reverseAlphabeticallyByKey) Less(i, j int) bool {
- return strings.Compare(a[i].key, a[j].key) > 0
-}