aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorTaketoshi Fujiwara <tfujiwar@users.noreply.github.com>2023-01-05 18:35:52 +0900
committerGitHub <noreply@github.com>2023-01-05 10:35:52 +0100
commit5dabd83e3712e2554745c736b55df405a0ba4f33 (patch)
tree319aeb1098c9eaa43db4e4ee587cb6f39a01039e /worktree_test.go
parent6839cd553d609fe7f4ac9d4fb6975950fa832063 (diff)
downloadgo-git-5dabd83e3712e2554745c736b55df405a0ba4f33.tar.gz
Worktree: Add, fix add removed files. Fixes #223 (#652)v5.5.2
Diffstat (limited to 'worktree_test.go')
-rw-r--r--worktree_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/worktree_test.go b/worktree_test.go
index 4c06333..d545b01 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -1398,6 +1398,51 @@ func (s *WorktreeSuite) TestAddRemoved(c *C) {
c.Assert(file.Staging, Equals, Deleted)
}
+func (s *WorktreeSuite) TestAddRemovedInDirectory(c *C) {
+ fs := memfs.New()
+ w := &Worktree{
+ r: s.Repository,
+ Filesystem: fs,
+ }
+
+ err := w.Checkout(&CheckoutOptions{Force: true})
+ c.Assert(err, IsNil)
+
+ idx, err := w.r.Storer.Index()
+ c.Assert(err, IsNil)
+ c.Assert(idx.Entries, HasLen, 9)
+
+ err = w.Filesystem.Remove("go/example.go")
+ c.Assert(err, IsNil)
+
+ err = w.Filesystem.Remove("json/short.json")
+ c.Assert(err, IsNil)
+
+ hash, err := w.Add("go")
+ c.Assert(err, IsNil)
+ c.Assert(hash.IsZero(), Equals, true)
+
+ e, err := idx.Entry("go/example.go")
+ c.Assert(err, IsNil)
+ c.Assert(e.Hash, Equals, plumbing.NewHash("880cd14280f4b9b6ed3986d6671f907d7cc2a198"))
+ c.Assert(e.Mode, Equals, filemode.Regular)
+
+ e, err = idx.Entry("json/short.json")
+ c.Assert(err, IsNil)
+ c.Assert(e.Hash, Equals, plumbing.NewHash("c8f1d8c61f9da76f4cb49fd86322b6e685dba956"))
+ c.Assert(e.Mode, Equals, filemode.Regular)
+
+ status, err := w.Status()
+ c.Assert(err, IsNil)
+ c.Assert(status, HasLen, 2)
+
+ file := status.File("go/example.go")
+ c.Assert(file.Staging, Equals, Deleted)
+
+ file = status.File("json/short.json")
+ c.Assert(file.Staging, Equals, Unmodified)
+}
+
func (s *WorktreeSuite) TestAddSymlink(c *C) {
dir, clean := s.TemporalDir()
defer clean()