| 1771 | } |
| 1772 | |
| 1773 | func (s *WorktreeSuite) TestAddRemoved(c *C) { |
| 1774 | fs := memfs.New() |
| 1775 | w := &Worktree{ |
| 1776 | r: s.Repository, |
| 1777 | Filesystem: fs, |
| 1778 | } |
| 1779 | |
| 1780 | err := w.Checkout(&CheckoutOptions{Force: true}) |
| 1781 | c.Assert(err, IsNil) |
| 1782 | |
| 1783 | idx, err := w.r.Storer.Index() |
| 1784 | c.Assert(err, IsNil) |
| 1785 | c.Assert(idx.Entries, HasLen, 9) |
| 1786 | |
| 1787 | err = w.Filesystem.Remove("LICENSE") |
| 1788 | c.Assert(err, IsNil) |
| 1789 | |
| 1790 | hash, err := w.Add("LICENSE") |
| 1791 | c.Assert(err, IsNil) |
| 1792 | c.Assert(hash.String(), Equals, "c192bd6a24ea1ab01d78686e417c8bdc7c3d197f") |
| 1793 | |
| 1794 | e, err := idx.Entry("LICENSE") |
| 1795 | c.Assert(err, IsNil) |
| 1796 | c.Assert(e.Hash, Equals, hash) |
| 1797 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1798 | |
| 1799 | status, err := w.Status() |
| 1800 | c.Assert(err, IsNil) |
| 1801 | c.Assert(status, HasLen, 1) |
| 1802 | |
| 1803 | file := status.File("LICENSE") |
| 1804 | c.Assert(file.Staging, Equals, Deleted) |
| 1805 | } |
| 1806 | |
| 1807 | func (s *WorktreeSuite) TestAddRemovedInDirectory(c *C) { |
| 1808 | fs := memfs.New() |