| 1895 | } |
| 1896 | |
| 1897 | func (s *WorktreeSuite) TestAddRemovedInDirectoryDot(c *C) { |
| 1898 | fs := memfs.New() |
| 1899 | w := &Worktree{ |
| 1900 | r: s.Repository, |
| 1901 | Filesystem: fs, |
| 1902 | } |
| 1903 | |
| 1904 | err := w.Checkout(&CheckoutOptions{Force: true}) |
| 1905 | c.Assert(err, IsNil) |
| 1906 | |
| 1907 | idx, err := w.r.Storer.Index() |
| 1908 | c.Assert(err, IsNil) |
| 1909 | c.Assert(idx.Entries, HasLen, 9) |
| 1910 | |
| 1911 | err = w.Filesystem.Remove("go/example.go") |
| 1912 | c.Assert(err, IsNil) |
| 1913 | |
| 1914 | err = w.Filesystem.Remove("json/short.json") |
| 1915 | c.Assert(err, IsNil) |
| 1916 | |
| 1917 | hash, err := w.Add(".") |
| 1918 | c.Assert(err, IsNil) |
| 1919 | c.Assert(hash.IsZero(), Equals, true) |
| 1920 | |
| 1921 | e, err := idx.Entry("go/example.go") |
| 1922 | c.Assert(err, IsNil) |
| 1923 | c.Assert(e.Hash, Equals, plumbing.NewHash("880cd14280f4b9b6ed3986d6671f907d7cc2a198")) |
| 1924 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1925 | |
| 1926 | e, err = idx.Entry("json/short.json") |
| 1927 | c.Assert(err, IsNil) |
| 1928 | c.Assert(e.Hash, Equals, plumbing.NewHash("c8f1d8c61f9da76f4cb49fd86322b6e685dba956")) |
| 1929 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1930 | |
| 1931 | status, err := w.Status() |
| 1932 | c.Assert(err, IsNil) |
| 1933 | c.Assert(status, HasLen, 2) |
| 1934 | |
| 1935 | file := status.File("go/example.go") |
| 1936 | c.Assert(file.Staging, Equals, Deleted) |
| 1937 | |
| 1938 | file = status.File("json/short.json") |
| 1939 | c.Assert(file.Staging, Equals, Deleted) |
| 1940 | } |
| 1941 | |
| 1942 | func (s *WorktreeSuite) TestAddSymlink(c *C) { |
| 1943 | dir := c.MkDir() |