| 2039 | } |
| 2040 | |
| 2041 | func (s *WorktreeSuite) TestAddSkipStatusWithIgnoredPath(c *C) { |
| 2042 | fs := memfs.New() |
| 2043 | w := &Worktree{ |
| 2044 | r: s.Repository, |
| 2045 | Filesystem: fs, |
| 2046 | } |
| 2047 | |
| 2048 | err := w.Checkout(&CheckoutOptions{Force: true}) |
| 2049 | c.Assert(err, IsNil) |
| 2050 | |
| 2051 | idx, err := w.r.Storer.Index() |
| 2052 | c.Assert(err, IsNil) |
| 2053 | c.Assert(idx.Entries, HasLen, 9) |
| 2054 | |
| 2055 | err = util.WriteFile(fs, ".gitignore", []byte("fileToIgnore\n"), 0755) |
| 2056 | c.Assert(err, IsNil) |
| 2057 | _, err = w.Add(".gitignore") |
| 2058 | c.Assert(err, IsNil) |
| 2059 | _, err = w.Commit("Added .gitignore", defaultTestCommitOptions) |
| 2060 | c.Assert(err, IsNil) |
| 2061 | |
| 2062 | err = util.WriteFile(fs, "fileToIgnore", []byte("file to ignore"), 0644) |
| 2063 | c.Assert(err, IsNil) |
| 2064 | |
| 2065 | status, err := w.Status() |
| 2066 | c.Assert(err, IsNil) |
| 2067 | c.Assert(status, HasLen, 0) |
| 2068 | |
| 2069 | file := status.File("fileToIgnore") |
| 2070 | c.Assert(file.Staging, Equals, Untracked) |
| 2071 | c.Assert(file.Worktree, Equals, Untracked) |
| 2072 | |
| 2073 | err = w.AddWithOptions(&AddOptions{Path: "fileToIgnore", SkipStatus: true}) |
| 2074 | c.Assert(err, IsNil) |
| 2075 | |
| 2076 | idx, err = w.r.Storer.Index() |
| 2077 | c.Assert(err, IsNil) |
| 2078 | c.Assert(idx.Entries, HasLen, 10) |
| 2079 | |
| 2080 | e, err := idx.Entry("fileToIgnore") |
| 2081 | c.Assert(err, IsNil) |
| 2082 | c.Assert(e.Mode, Equals, filemode.Regular) |
| 2083 | |
| 2084 | status, err = w.Status() |
| 2085 | c.Assert(err, IsNil) |
| 2086 | c.Assert(status, HasLen, 1) |
| 2087 | |
| 2088 | file = status.File("fileToIgnore") |
| 2089 | c.Assert(file.Staging, Equals, Added) |
| 2090 | c.Assert(file.Worktree, Equals, Unmodified) |
| 2091 | } |
| 2092 | |
| 2093 | func (s *WorktreeSuite) TestRemove(c *C) { |
| 2094 | fs := memfs.New() |