| 1850 | } |
| 1851 | |
| 1852 | func (s *WorktreeSuite) TestAddRemovedInDirectoryWithTrailingSlash(c *C) { |
| 1853 | fs := memfs.New() |
| 1854 | w := &Worktree{ |
| 1855 | r: s.Repository, |
| 1856 | Filesystem: fs, |
| 1857 | } |
| 1858 | |
| 1859 | err := w.Checkout(&CheckoutOptions{Force: true}) |
| 1860 | c.Assert(err, IsNil) |
| 1861 | |
| 1862 | idx, err := w.r.Storer.Index() |
| 1863 | c.Assert(err, IsNil) |
| 1864 | c.Assert(idx.Entries, HasLen, 9) |
| 1865 | |
| 1866 | err = w.Filesystem.Remove("go/example.go") |
| 1867 | c.Assert(err, IsNil) |
| 1868 | |
| 1869 | err = w.Filesystem.Remove("json/short.json") |
| 1870 | c.Assert(err, IsNil) |
| 1871 | |
| 1872 | hash, err := w.Add("go/") |
| 1873 | c.Assert(err, IsNil) |
| 1874 | c.Assert(hash.IsZero(), Equals, true) |
| 1875 | |
| 1876 | e, err := idx.Entry("go/example.go") |
| 1877 | c.Assert(err, IsNil) |
| 1878 | c.Assert(e.Hash, Equals, plumbing.NewHash("880cd14280f4b9b6ed3986d6671f907d7cc2a198")) |
| 1879 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1880 | |
| 1881 | e, err = idx.Entry("json/short.json") |
| 1882 | c.Assert(err, IsNil) |
| 1883 | c.Assert(e.Hash, Equals, plumbing.NewHash("c8f1d8c61f9da76f4cb49fd86322b6e685dba956")) |
| 1884 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1885 | |
| 1886 | status, err := w.Status() |
| 1887 | c.Assert(err, IsNil) |
| 1888 | c.Assert(status, HasLen, 2) |
| 1889 | |
| 1890 | file := status.File("go/example.go") |
| 1891 | c.Assert(file.Staging, Equals, Deleted) |
| 1892 | |
| 1893 | file = status.File("json/short.json") |
| 1894 | c.Assert(file.Staging, Equals, Unmodified) |
| 1895 | } |
| 1896 | |
| 1897 | func (s *WorktreeSuite) TestAddRemovedInDirectoryDot(c *C) { |
| 1898 | fs := memfs.New() |