+1
-1
utils/merkletrie/change.go
+1
-1
utils/merkletrie/change.go
+9
-1
utils/merkletrie/index/node.go
+9
-1
utils/merkletrie/index/node.go
···
36
36
parent := fullpath
37
37
fullpath = path.Join(fullpath, part)
38
38
39
-
if _, ok := m[fullpath]; ok {
39
+
// It's possible that the first occurrence of subdirectory is skipped.
40
+
// The parent node can be created with SkipWorktree set to true, but
41
+
// if any future children do not skip their subtree, the entire lineage
42
+
// of the tree needs to have this value set to false so that subdirectories
43
+
// are not ignored.
44
+
if parentNode, ok := m[fullpath]; ok {
45
+
if e.SkipWorktree == false {
46
+
parentNode.skip = false
47
+
}
40
48
continue
41
49
}
42
50
+30
-4
utils/merkletrie/index/node_test.go
+30
-4
utils/merkletrie/index/node_test.go
···
2
2
3
3
import (
4
4
"bytes"
5
-
"path/filepath"
5
+
"path"
6
6
"testing"
7
7
8
8
"github.com/go-git/go-git/v5/plumbing"
···
47
47
func (s *NoderSuite) TestDiffChange() {
48
48
indexA := &index.Index{
49
49
Entries: []*index.Entry{{
50
-
Name: filepath.Join("bar", "baz", "bar"),
50
+
Name: path.Join("bar", "baz", "bar"),
51
51
Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d"),
52
52
}},
53
53
}
54
54
55
55
indexB := &index.Index{
56
56
Entries: []*index.Entry{{
57
-
Name: filepath.Join("bar", "baz", "foo"),
57
+
Name: path.Join("bar", "baz", "foo"),
58
58
Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d"),
59
59
}},
60
60
}
···
64
64
s.Len(ch, 2)
65
65
}
66
66
67
+
func (s *NoderSuite) TestDiffSkipIssue1455() {
68
+
indexA := &index.Index{
69
+
Entries: []*index.Entry{
70
+
{
71
+
Name: path.Join("bar", "baz", "bar"),
72
+
Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d"),
73
+
SkipWorktree: true,
74
+
},
75
+
{
76
+
Name: path.Join("bar", "biz", "bat"),
77
+
Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d"),
78
+
SkipWorktree: false,
79
+
},
80
+
},
81
+
}
82
+
83
+
indexB := &index.Index{}
84
+
85
+
ch, err := merkletrie.DiffTree(NewRootNode(indexB), NewRootNode(indexA), isEquals)
86
+
s.NoError(err)
87
+
s.Len(ch, 1)
88
+
a, err := ch[0].Action()
89
+
s.NoError(err)
90
+
s.Equal(a, merkletrie.Insert)
91
+
}
92
+
67
93
func (s *NoderSuite) TestDiffDir() {
68
94
indexA := &index.Index{
69
95
Entries: []*index.Entry{{
···
74
100
75
101
indexB := &index.Index{
76
102
Entries: []*index.Entry{{
77
-
Name: filepath.Join("foo", "bar"),
103
+
Name: path.Join("foo", "bar"),
78
104
Hash: plumbing.NewHash("8ab686eafeb1f44702738c8b0f24f2567c36da6d"),
79
105
}},
80
106
}