diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-04-11 23:20:06 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-04-11 23:20:06 +0200 |
commit | e14ee7a2645b486d72f52a0c62714b3049077554 (patch) | |
tree | b3acc4ebfedd7f70289f47bd520a7e2d0514e4d3 /plumbing/object | |
parent | 7a428a915ce2b7bb0f4fc6dcee77932ebacfabbf (diff) | |
download | go-git-e14ee7a2645b486d72f52a0c62714b3049077554.tar.gz |
merkletrie: filesystem and index speedup and documentation
Diffstat (limited to 'plumbing/object')
-rw-r--r-- | plumbing/object/treenoder.go | 29 |
1 files changed, 11 insertions, 18 deletions
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 } |