diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2021-12-10 06:49:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 06:49:09 +0100 |
commit | 39f97ab86a776dd8acd58a79a660d0cfdb7068c0 (patch) | |
tree | 119b9f5b10f2fd1053c430e1891b0e33d927615b /plumbing | |
parent | c71074e855b42c817c6ecb6cba7e6b62eafc08d3 (diff) | |
parent | f92011d95f98f5deea4959c7d432704a4300d3a8 (diff) | |
download | go-git-39f97ab86a776dd8acd58a79a660d0cfdb7068c0.tar.gz |
Merge pull request #410 from john-cai/jc-sparse
Worktree: Checkout, simplified sparse checkout
Diffstat (limited to 'plumbing')
-rw-r--r-- | plumbing/format/index/index.go | 18 | ||||
-rw-r--r-- | plumbing/object/treenoder.go | 4 |
2 files changed, 22 insertions, 0 deletions
diff --git a/plumbing/format/index/index.go b/plumbing/format/index/index.go index 649416a..f4c7647 100644 --- a/plumbing/format/index/index.go +++ b/plumbing/format/index/index.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "path/filepath" + "strings" "time" "github.com/go-git/go-git/v5/plumbing" @@ -211,3 +212,20 @@ type EndOfIndexEntry struct { // their contents). Hash plumbing.Hash } + +// SkipUnless applies patterns in the form of A, A/B, A/B/C +// to the index to prevent the files from being checked out +func (i *Index) SkipUnless(patterns []string) { + for _, e := range i.Entries { + var include bool + for _, pattern := range patterns { + if strings.HasPrefix(e.Name, pattern) { + include = true + break + } + } + if !include { + e.SkipWorktree = true + } + } +} diff --git a/plumbing/object/treenoder.go b/plumbing/object/treenoder.go index b4891b9..6e7b334 100644 --- a/plumbing/object/treenoder.go +++ b/plumbing/object/treenoder.go @@ -38,6 +38,10 @@ func NewTreeRootNode(t *Tree) noder.Noder { } } +func (t *treeNoder) Skip() bool { + return false +} + func (t *treeNoder) isRoot() bool { return t.name == "" } |