| 1571 | } |
| 1572 | |
| 1573 | func (s *WorktreeSuite) TestAddRemoved(c *C) { |
| 1574 | fs := memfs.New() |
| 1575 | w := &Worktree{ |
| 1576 | r: s.Repository, |
| 1577 | Filesystem: fs, |
| 1578 | } |
| 1579 | |
| 1580 | err := w.Checkout(&CheckoutOptions{Force: true}) |
| 1581 | c.Assert(err, IsNil) |
| 1582 | |
| 1583 | idx, err := w.r.Storer.Index() |
| 1584 | c.Assert(err, IsNil) |
| 1585 | c.Assert(idx.Entries, HasLen, 9) |
| 1586 | |
| 1587 | err = w.Filesystem.Remove("LICENSE") |
| 1588 | c.Assert(err, IsNil) |
| 1589 | |
| 1590 | hash, err := w.Add("LICENSE") |
| 1591 | c.Assert(err, IsNil) |
| 1592 | c.Assert(hash.String(), Equals, "c192bd6a24ea1ab01d78686e417c8bdc7c3d197f") |
| 1593 | |
| 1594 | e, err := idx.Entry("LICENSE") |
| 1595 | c.Assert(err, IsNil) |
| 1596 | c.Assert(e.Hash, Equals, hash) |
| 1597 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1598 | |
| 1599 | status, err := w.Status() |
| 1600 | c.Assert(err, IsNil) |
| 1601 | c.Assert(status, HasLen, 1) |
| 1602 | |
| 1603 | file := status.File("LICENSE") |
| 1604 | c.Assert(file.Staging, Equals, Deleted) |
| 1605 | } |
| 1606 | |
| 1607 | func (s *WorktreeSuite) TestAddRemovedInDirectory(c *C) { |
| 1608 | fs := memfs.New() |