@@ -2,7 +2,7 @@ package index
22
33import (
44 "bytes"
5- "path/filepath "
5+ "path"
66 "testing"
77
88 "github.com/go-git/go-git/v5/plumbing"
@@ -46,14 +46,14 @@ func (s *NoderSuite) TestDiff(c *C) {
4646func (s * NoderSuite ) TestDiffChange (c * C ) {
4747 indexA := & index.Index {
4848 Entries : []* index.Entry {{
49- Name : filepath .Join ("bar" , "baz" , "bar" ),
49+ Name : path .Join ("bar" , "baz" , "bar" ),
5050 Hash : plumbing .NewHash ("8ab686eafeb1f44702738c8b0f24f2567c36da6d" ),
5151 }},
5252 }
5353
5454 indexB := & index.Index {
5555 Entries : []* index.Entry {{
56- Name : filepath .Join ("bar" , "baz" , "foo" ),
56+ Name : path .Join ("bar" , "baz" , "foo" ),
5757 Hash : plumbing .NewHash ("8ab686eafeb1f44702738c8b0f24f2567c36da6d" ),
5858 }},
5959 }
@@ -63,6 +63,32 @@ func (s *NoderSuite) TestDiffChange(c *C) {
6363 c .Assert (ch , HasLen , 2 )
6464}
6565
66+ func (s * NoderSuite ) TestDiffSkipIssue1455 (c * C ) {
67+ indexA := & index.Index {
68+ Entries : []* index.Entry {
69+ {
70+ Name : path .Join ("bar" , "baz" , "bar" ),
71+ Hash : plumbing .NewHash ("8ab686eafeb1f44702738c8b0f24f2567c36da6d" ),
72+ SkipWorktree : true ,
73+ },
74+ {
75+ Name : path .Join ("bar" , "biz" , "bat" ),
76+ Hash : plumbing .NewHash ("8ab686eafeb1f44702738c8b0f24f2567c36da6d" ),
77+ SkipWorktree : false ,
78+ },
79+ },
80+ }
81+
82+ indexB := & index.Index {}
83+
84+ ch , err := merkletrie .DiffTree (NewRootNode (indexB ), NewRootNode (indexA ), isEquals )
85+ c .Assert (err , IsNil )
86+ c .Assert (ch , HasLen , 1 )
87+ a , err := ch [0 ].Action ()
88+ c .Assert (err , IsNil )
89+ c .Assert (a , Equals , merkletrie .Insert )
90+ }
91+
6692func (s * NoderSuite ) TestDiffDir (c * C ) {
6793 indexA := & index.Index {
6894 Entries : []* index.Entry {{
@@ -73,7 +99,7 @@ func (s *NoderSuite) TestDiffDir(c *C) {
7399
74100 indexB := & index.Index {
75101 Entries : []* index.Entry {{
76- Name : filepath .Join ("foo" , "bar" ),
102+ Name : path .Join ("foo" , "bar" ),
77103 Hash : plumbing .NewHash ("8ab686eafeb1f44702738c8b0f24f2567c36da6d" ),
78104 }},
79105 }
0 commit comments