aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/ioutil/common.go8
-rw-r--r--utils/merkletrie/difftree.go2
-rw-r--r--utils/merkletrie/filesystem/node.go7
-rw-r--r--utils/merkletrie/filesystem/node_test.go40
-rw-r--r--utils/merkletrie/iter.go2
-rw-r--r--utils/merkletrie/noder/path.go2
6 files changed, 51 insertions, 10 deletions
diff --git a/utils/ioutil/common.go b/utils/ioutil/common.go
index 66044e2..e9dcbfe 100644
--- a/utils/ioutil/common.go
+++ b/utils/ioutil/common.go
@@ -123,13 +123,13 @@ type readerOnError struct {
}
// NewReaderOnError returns a io.Reader that call the notify function when an
-// unexpected (!io.EOF) error happends, after call Read function.
+// unexpected (!io.EOF) error happens, after call Read function.
func NewReaderOnError(r io.Reader, notify func(error)) io.Reader {
return &readerOnError{r, notify}
}
// NewReadCloserOnError returns a io.ReadCloser that call the notify function
-// when an unexpected (!io.EOF) error happends, after call Read function.
+// when an unexpected (!io.EOF) error happens, after call Read function.
func NewReadCloserOnError(r io.ReadCloser, notify func(error)) io.ReadCloser {
return NewReadCloser(NewReaderOnError(r, notify), r)
}
@@ -149,13 +149,13 @@ type writerOnError struct {
}
// NewWriterOnError returns a io.Writer that call the notify function when an
-// unexpected (!io.EOF) error happends, after call Write function.
+// unexpected (!io.EOF) error happens, after call Write function.
func NewWriterOnError(w io.Writer, notify func(error)) io.Writer {
return &writerOnError{w, notify}
}
// NewWriteCloserOnError returns a io.WriteCloser that call the notify function
-//when an unexpected (!io.EOF) error happends, after call Write function.
+//when an unexpected (!io.EOF) error happens, after call Write function.
func NewWriteCloserOnError(w io.WriteCloser, notify func(error)) io.WriteCloser {
return NewWriteCloser(NewWriterOnError(w, notify), w)
}
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.