@@ -2007,6 +2007,66 @@ func (s *WorktreeSuite) TestAddGlob(c *C) {
2007
2007
c .Assert (file .Worktree , Equals , Unmodified )
2008
2008
}
2009
2009
2010
+ func (s * WorktreeSuite ) TestAddFilenameStartingWithDot (c * C ) {
2011
+ fs := memfs .New ()
2012
+ w := & Worktree {
2013
+ r : s .Repository ,
2014
+ Filesystem : fs ,
2015
+ }
2016
+
2017
+ err := w .Checkout (& CheckoutOptions {Force : true })
2018
+ c .Assert (err , IsNil )
2019
+
2020
+ idx , err := w .r .Storer .Index ()
2021
+ c .Assert (err , IsNil )
2022
+ c .Assert (idx .Entries , HasLen , 9 )
2023
+
2024
+ err = util .WriteFile (w .Filesystem , "qux" , []byte ("QUX" ), 0o755 )
2025
+ c .Assert (err , IsNil )
2026
+ err = util .WriteFile (w .Filesystem , "baz" , []byte ("BAZ" ), 0o755 )
2027
+ c .Assert (err , IsNil )
2028
+ err = util .WriteFile (w .Filesystem , "foo/bar/baz" , []byte ("BAZ" ), 0o755 )
2029
+ c .Assert (err , IsNil )
2030
+
2031
+ _ , err = w .Add ("./qux" )
2032
+ c .Assert (err , IsNil )
2033
+
2034
+ _ , err = w .Add ("./baz" )
2035
+ c .Assert (err , IsNil )
2036
+
2037
+ _ , err = w .Add ("foo/bar/../bar/./baz" )
2038
+ c .Assert (err , IsNil )
2039
+
2040
+ idx , err = w .r .Storer .Index ()
2041
+ c .Assert (err , IsNil )
2042
+ c .Assert (idx .Entries , HasLen , 12 )
2043
+
2044
+ e , err := idx .Entry ("qux" )
2045
+ c .Assert (err , IsNil )
2046
+ c .Assert (e .Mode , Equals , filemode .Executable )
2047
+
2048
+ e , err = idx .Entry ("baz" )
2049
+ c .Assert (err , IsNil )
2050
+ c .Assert (e .Mode , Equals , filemode .Executable )
2051
+
2052
+ status , err := w .Status ()
2053
+ c .Assert (err , IsNil )
2054
+ c .Assert (status , HasLen , 3 )
2055
+
2056
+ file := status .File ("qux" )
2057
+ c .Assert (file .Staging , Equals , Added )
2058
+ c .Assert (file .Worktree , Equals , Unmodified )
2059
+
2060
+ file = status .File ("baz" )
2061
+ c .Assert (file .Staging , Equals , Added )
2062
+ c .Assert (file .Worktree , Equals , Unmodified )
2063
+
2064
+ file = status .File ("foo/bar/baz" )
2065
+ c .Assert (file .Staging , Equals , Added )
2066
+ c .Assert (file .Worktree , Equals , Unmodified )
2067
+
2068
+ }
2069
+
2010
2070
func (s * WorktreeSuite ) TestAddGlobErrorNoMatches (c * C ) {
2011
2071
r , _ := Init (memory .NewStorage (), memfs .New ())
2012
2072
w , _ := r .Worktree ()
0 commit comments