aboutsummaryrefslogtreecommitdiffstats
path: root/utils/merkletrie/noder
diff options
context:
space:
mode:
authorJohn Cai <johncai86@gmail.com>2021-11-04 15:02:00 -0400
committerJohn Cai <jcai@gitlab.com>2021-11-09 08:45:09 -0500
commitf92011d95f98f5deea4959c7d432704a4300d3a8 (patch)
tree6929972e94cc168ca210532954b234b55bb24165 /utils/merkletrie/noder
parente4fcd078d42e945581616855ab78d8b7ed12df6c (diff)
downloadgo-git-f92011d95f98f5deea4959c7d432704a4300d3a8.tar.gz
simplified sparse checkout
This is the initial logic to support a simple sparse checkout where directories to be included can be specified in CheckoutOptions. This change doesn't fully support the sparse patterns, nor does this change include the optimization to collapse flie entries in ithe index that are excluded via the sparse checkout directory patterns included under the parent directory.
Diffstat (limited to 'utils/merkletrie/noder')
-rw-r--r--utils/merkletrie/noder/noder.go1
-rw-r--r--utils/merkletrie/noder/noder_test.go1
-rw-r--r--utils/merkletrie/noder/path.go8
3 files changed, 10 insertions, 0 deletions
diff --git a/utils/merkletrie/noder/noder.go b/utils/merkletrie/noder/noder.go
index d6b3de4..6d22b8c 100644
--- a/utils/merkletrie/noder/noder.go
+++ b/utils/merkletrie/noder/noder.go
@@ -53,6 +53,7 @@ type Noder interface {
// implement NumChildren in O(1) while Children is usually more
// complex.
NumChildren() (int, error)
+ Skip() bool
}
// NoChildren represents the children of a noder without children.
diff --git a/utils/merkletrie/noder/noder_test.go b/utils/merkletrie/noder/noder_test.go
index 5e014fe..ccebdc9 100644
--- a/utils/merkletrie/noder/noder_test.go
+++ b/utils/merkletrie/noder/noder_test.go
@@ -25,6 +25,7 @@ func (n noderMock) Name() string { return n.name }
func (n noderMock) IsDir() bool { return n.isDir }
func (n noderMock) Children() ([]Noder, error) { return n.children, nil }
func (n noderMock) NumChildren() (int, error) { return len(n.children), nil }
+func (n noderMock) Skip() bool { return false }
// Returns a sequence with the noders 3, 2, and 1 from the
// following diagram:
diff --git a/utils/merkletrie/noder/path.go b/utils/merkletrie/noder/path.go
index 1c7ef54..6c1d363 100644
--- a/utils/merkletrie/noder/path.go
+++ b/utils/merkletrie/noder/path.go
@@ -15,6 +15,14 @@ import (
// not be used.
type Path []Noder
+func (p Path) Skip() bool {
+ if len(p) > 0 {
+ return p.Last().Skip()
+ }
+
+ return false
+}
+
// String returns the full path of the final noder as a string, using
// "/" as the separator.
func (p Path) String() string {