| 1650 | } |
| 1651 | |
| 1652 | func (s *WorktreeSuite) TestAddRemovedInDirectoryWithTrailingSlash(c *C) { |
| 1653 | fs := memfs.New() |
| 1654 | w := &Worktree{ |
| 1655 | r: s.Repository, |
| 1656 | Filesystem: fs, |
| 1657 | } |
| 1658 | |
| 1659 | err := w.Checkout(&CheckoutOptions{Force: true}) |
| 1660 | c.Assert(err, IsNil) |
| 1661 | |
| 1662 | idx, err := w.r.Storer.Index() |
| 1663 | c.Assert(err, IsNil) |
| 1664 | c.Assert(idx.Entries, HasLen, 9) |
| 1665 | |
| 1666 | err = w.Filesystem.Remove("go/example.go") |
| 1667 | c.Assert(err, IsNil) |
| 1668 | |
| 1669 | err = w.Filesystem.Remove("json/short.json") |
| 1670 | c.Assert(err, IsNil) |
| 1671 | |
| 1672 | hash, err := w.Add("go/") |
| 1673 | c.Assert(err, IsNil) |
| 1674 | c.Assert(hash.IsZero(), Equals, true) |
| 1675 | |
| 1676 | e, err := idx.Entry("go/example.go") |
| 1677 | c.Assert(err, IsNil) |
| 1678 | c.Assert(e.Hash, Equals, plumbing.NewHash("880cd14280f4b9b6ed3986d6671f907d7cc2a198")) |
| 1679 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1680 | |
| 1681 | e, err = idx.Entry("json/short.json") |
| 1682 | c.Assert(err, IsNil) |
| 1683 | c.Assert(e.Hash, Equals, plumbing.NewHash("c8f1d8c61f9da76f4cb49fd86322b6e685dba956")) |
| 1684 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1685 | |
| 1686 | status, err := w.Status() |
| 1687 | c.Assert(err, IsNil) |
| 1688 | c.Assert(status, HasLen, 2) |
| 1689 | |
| 1690 | file := status.File("go/example.go") |
| 1691 | c.Assert(file.Staging, Equals, Deleted) |
| 1692 | |
| 1693 | file = status.File("json/short.json") |
| 1694 | c.Assert(file.Staging, Equals, Unmodified) |
| 1695 | } |
| 1696 | |
| 1697 | func (s *WorktreeSuite) TestAddRemovedInDirectoryDot(c *C) { |
| 1698 | fs := memfs.New() |