From aa818a3f77e6ff06765cf8c246f8708df3d190a7 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Tue, 11 Apr 2017 20:03:00 +0200 Subject: plumbing: object, public Tree.FindEntry and minor diff changes --- plumbing/object/treenoder.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'plumbing/object/treenoder.go') diff --git a/plumbing/object/treenoder.go b/plumbing/object/treenoder.go index 4da8298..8b56d1b 100644 --- a/plumbing/object/treenoder.go +++ b/plumbing/object/treenoder.go @@ -21,10 +21,11 @@ type treeNoder struct { name string // empty string for the root node mode filemode.FileMode hash plumbing.Hash - children []noder.Noder // memoized + children []noder.Noder // memorized } -func newTreeNoder(t *Tree) *treeNoder { +// NewTreeRootNode returns the root node of a Tree +func NewTreeRootNode(t *Tree) *treeNoder { if t == nil { return &treeNoder{} } @@ -74,7 +75,7 @@ func (t *treeNoder) Children() ([]noder.Noder, error) { return noder.NoChildren, nil } - // children are memoized for efficiency + // children are memorized for efficiency if t.children != nil { return t.children, nil } -- cgit From e14ee7a2645b486d72f52a0c62714b3049077554 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Tue, 11 Apr 2017 23:20:06 +0200 Subject: merkletrie: filesystem and index speedup and documentation --- plumbing/object/treenoder.go | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'plumbing/object/treenoder.go') diff --git a/plumbing/object/treenoder.go b/plumbing/object/treenoder.go index 8b56d1b..bd65abc 100644 --- a/plumbing/object/treenoder.go +++ b/plumbing/object/treenoder.go @@ -1,13 +1,5 @@ package object -// A treenoder is a helper type that wraps git trees into merkletrie -// noders. -// -// As a merkletrie noder doesn't understand the concept of modes (e.g. -// file permissions), the treenoder includes the mode of the git tree in -// the hash, so changes in the modes will be detected as modifications -// to the file contents by the merkletrie difftree algorithm. This is -// consistent with how the "git diff-tree" command works. import ( "io" @@ -16,16 +8,24 @@ import ( "gopkg.in/src-d/go-git.v4/utils/merkletrie/noder" ) +// A treenoder is a helper type that wraps git trees into merkletrie +// noders. +// +// As a merkletrie noder doesn't understand the concept of modes (e.g. +// file permissions), the treenoder includes the mode of the git tree in +// the hash, so changes in the modes will be detected as modifications +// to the file contents by the merkletrie difftree algorithm. This is +// consistent with how the "git diff-tree" command works. type treeNoder struct { parent *Tree // the root node is its own parent name string // empty string for the root node mode filemode.FileMode hash plumbing.Hash - children []noder.Noder // memorized + children []noder.Noder // memoized } // NewTreeRootNode returns the root node of a Tree -func NewTreeRootNode(t *Tree) *treeNoder { +func NewTreeRootNode(t *Tree) noder.Noder { if t == nil { return &treeNoder{} } @@ -46,13 +46,6 @@ func (t *treeNoder) String() string { return "treeNoder <" + t.name + ">" } -// The hash of a treeNoder is the result of concatenating the hash of -// its contents and its mode; that way the difftree algorithm will -// detect changes in the contents of files and also in their mode. -// -// Files with Regular and Deprecated file modes are considered the same -// for the purpose of difftree, so Regular will be used as the mode for -// Deprecated files here. func (t *treeNoder) Hash() []byte { if t.mode == filemode.Deprecated { return append(t.hash[:], filemode.Regular.Bytes()...) @@ -75,7 +68,7 @@ func (t *treeNoder) Children() ([]noder.Noder, error) { return noder.NoChildren, nil } - // children are memorized for efficiency + // children are memoized for efficiency if t.children != nil { return t.children, nil } -- cgit