| 1695 | } |
| 1696 | |
| 1697 | func (s *WorktreeSuite) TestAddRemovedInDirectoryDot(c *C) { |
| 1698 | fs := memfs.New() |
| 1699 | w := &Worktree{ |
| 1700 | r: s.Repository, |
| 1701 | Filesystem: fs, |
| 1702 | } |
| 1703 | |
| 1704 | err := w.Checkout(&CheckoutOptions{Force: true}) |
| 1705 | c.Assert(err, IsNil) |
| 1706 | |
| 1707 | idx, err := w.r.Storer.Index() |
| 1708 | c.Assert(err, IsNil) |
| 1709 | c.Assert(idx.Entries, HasLen, 9) |
| 1710 | |
| 1711 | err = w.Filesystem.Remove("go/example.go") |
| 1712 | c.Assert(err, IsNil) |
| 1713 | |
| 1714 | err = w.Filesystem.Remove("json/short.json") |
| 1715 | c.Assert(err, IsNil) |
| 1716 | |
| 1717 | hash, err := w.Add(".") |
| 1718 | c.Assert(err, IsNil) |
| 1719 | c.Assert(hash.IsZero(), Equals, true) |
| 1720 | |
| 1721 | e, err := idx.Entry("go/example.go") |
| 1722 | c.Assert(err, IsNil) |
| 1723 | c.Assert(e.Hash, Equals, plumbing.NewHash("880cd14280f4b9b6ed3986d6671f907d7cc2a198")) |
| 1724 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1725 | |
| 1726 | e, err = idx.Entry("json/short.json") |
| 1727 | c.Assert(err, IsNil) |
| 1728 | c.Assert(e.Hash, Equals, plumbing.NewHash("c8f1d8c61f9da76f4cb49fd86322b6e685dba956")) |
| 1729 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1730 | |
| 1731 | status, err := w.Status() |
| 1732 | c.Assert(err, IsNil) |
| 1733 | c.Assert(status, HasLen, 2) |
| 1734 | |
| 1735 | file := status.File("go/example.go") |
| 1736 | c.Assert(file.Staging, Equals, Deleted) |
| 1737 | |
| 1738 | file = status.File("json/short.json") |
| 1739 | c.Assert(file.Staging, Equals, Deleted) |
| 1740 | } |
| 1741 | |
| 1742 | func (s *WorktreeSuite) TestAddSymlink(c *C) { |
| 1743 | dir, clean := s.TemporalDir() |