| 1517 | } |
| 1518 | |
| 1519 | func (s *WorktreeSuite) TestAddModified(c *C) { |
| 1520 | fs := memfs.New() |
| 1521 | w := &Worktree{ |
| 1522 | r: s.Repository, |
| 1523 | Filesystem: fs, |
| 1524 | } |
| 1525 | |
| 1526 | err := w.Checkout(&CheckoutOptions{Force: true}) |
| 1527 | c.Assert(err, IsNil) |
| 1528 | |
| 1529 | idx, err := w.r.Storer.Index() |
| 1530 | c.Assert(err, IsNil) |
| 1531 | c.Assert(idx.Entries, HasLen, 9) |
| 1532 | |
| 1533 | err = util.WriteFile(w.Filesystem, "LICENSE", []byte("FOO"), 0644) |
| 1534 | c.Assert(err, IsNil) |
| 1535 | |
| 1536 | hash, err := w.Add("LICENSE") |
| 1537 | c.Assert(err, IsNil) |
| 1538 | c.Assert(hash.String(), Equals, "d96c7efbfec2814ae0301ad054dc8d9fc416c9b5") |
| 1539 | |
| 1540 | idx, err = w.r.Storer.Index() |
| 1541 | c.Assert(err, IsNil) |
| 1542 | c.Assert(idx.Entries, HasLen, 9) |
| 1543 | |
| 1544 | e, err := idx.Entry("LICENSE") |
| 1545 | c.Assert(err, IsNil) |
| 1546 | c.Assert(e.Hash, Equals, hash) |
| 1547 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 1548 | |
| 1549 | status, err := w.Status() |
| 1550 | c.Assert(err, IsNil) |
| 1551 | c.Assert(status, HasLen, 1) |
| 1552 | |
| 1553 | file := status.File("LICENSE") |
| 1554 | c.Assert(file.Staging, Equals, Modified) |
| 1555 | c.Assert(file.Worktree, Equals, Unmodified) |
| 1556 | } |
| 1557 | |
| 1558 | func (s *WorktreeSuite) TestAddUnmodified(c *C) { |
| 1559 | fs := memfs.New() |