diff options
Diffstat (limited to 'utils/merkletrie')
-rw-r--r-- | utils/merkletrie/difftree.go | 2 | ||||
-rw-r--r-- | utils/merkletrie/filesystem/node.go | 7 | ||||
-rw-r--r-- | utils/merkletrie/filesystem/node_test.go | 40 | ||||
-rw-r--r-- | utils/merkletrie/iter.go | 2 | ||||
-rw-r--r-- | utils/merkletrie/noder/path.go | 2 |
5 files changed, 47 insertions, 6 deletions
diff --git a/utils/merkletrie/difftree.go b/utils/merkletrie/difftree.go index 0748865..2294096 100644 --- a/utils/merkletrie/difftree.go +++ b/utils/merkletrie/difftree.go @@ -54,7 +54,7 @@ package merkletrie // // Here is a full list of all the cases that are similar and how to // merge them together into more general cases. Each general case -// is labeled wiht an uppercase letter for further reference, and it +// is labeled with an uppercase letter for further reference, and it // is followed by the pseudocode of the checks you have to perfrom // on both noders to see if you are in such a case, the actions to // perform (i.e. what changes to output) and how to advance the diff --git a/utils/merkletrie/filesystem/node.go b/utils/merkletrie/filesystem/node.go index f763e08..12d0018 100644 --- a/utils/merkletrie/filesystem/node.go +++ b/utils/merkletrie/filesystem/node.go @@ -5,10 +5,11 @@ import ( "os" "path" - "gopkg.in/src-d/go-billy.v3" "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/plumbing/filemode" "gopkg.in/src-d/go-git.v4/utils/merkletrie/noder" + + "gopkg.in/src-d/go-billy.v4" ) var ignore = map[string]bool{ @@ -77,6 +78,10 @@ func (n *node) NumChildren() (int, error) { } func (n *node) calculateChildren() error { + if !n.IsDir() { + return nil + } + if len(n.children) != 0 { return nil } diff --git a/utils/merkletrie/filesystem/node_test.go b/utils/merkletrie/filesystem/node_test.go index 42dd82e..12f3412 100644 --- a/utils/merkletrie/filesystem/node_test.go +++ b/utils/merkletrie/filesystem/node_test.go @@ -8,8 +8,8 @@ import ( "testing" . "gopkg.in/check.v1" - "gopkg.in/src-d/go-billy.v3" - "gopkg.in/src-d/go-billy.v3/memfs" + "gopkg.in/src-d/go-billy.v4" + "gopkg.in/src-d/go-billy.v4/memfs" "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/utils/merkletrie" "gopkg.in/src-d/go-git.v4/utils/merkletrie/noder" @@ -82,6 +82,42 @@ func (s *NoderSuite) TestDiffChangeContent(c *C) { c.Assert(ch, HasLen, 1) } +func (s *NoderSuite) TestDiffSymlinkDirOnA(c *C) { + fsA := memfs.New() + WriteFile(fsA, "qux/qux", []byte("foo"), 0644) + + fsB := memfs.New() + fsB.Symlink("qux", "foo") + WriteFile(fsB, "qux/qux", []byte("foo"), 0644) + + ch, err := merkletrie.DiffTree( + NewRootNode(fsA, nil), + NewRootNode(fsB, nil), + IsEquals, + ) + + c.Assert(err, IsNil) + c.Assert(ch, HasLen, 1) +} + +func (s *NoderSuite) TestDiffSymlinkDirOnB(c *C) { + fsA := memfs.New() + fsA.Symlink("qux", "foo") + WriteFile(fsA, "qux/qux", []byte("foo"), 0644) + + fsB := memfs.New() + WriteFile(fsB, "qux/qux", []byte("foo"), 0644) + + ch, err := merkletrie.DiffTree( + NewRootNode(fsA, nil), + NewRootNode(fsB, nil), + IsEquals, + ) + + c.Assert(err, IsNil) + c.Assert(ch, HasLen, 1) +} + func (s *NoderSuite) TestDiffChangeMissing(c *C) { fsA := memfs.New() WriteFile(fsA, "foo", []byte("foo"), 0644) diff --git a/utils/merkletrie/iter.go b/utils/merkletrie/iter.go index e3f3055..b4d4c99 100644 --- a/utils/merkletrie/iter.go +++ b/utils/merkletrie/iter.go @@ -198,7 +198,7 @@ func (iter *Iter) current() (noder.Path, error) { } // removes the current node if any, and all the frames that become empty as a -// consecuence of this action. +// consequence of this action. func (iter *Iter) drop() { frame, ok := iter.top() if !ok { diff --git a/utils/merkletrie/noder/path.go b/utils/merkletrie/noder/path.go index d2e2932..e9c905c 100644 --- a/utils/merkletrie/noder/path.go +++ b/utils/merkletrie/noder/path.go @@ -8,7 +8,7 @@ import ( ) // Path values represent a noder and its ancestors. The root goes first -// and the actual final noder the path is refering to will be the last. +// and the actual final noder the path is referring to will be the last. // // A path implements the Noder interface, redirecting all the interface // calls to its final noder. |