Add adds the file contents of a file in the worktree to the index. if the file is already staged in the index no error is returned. If a file deleted from the Workspace is given, the file is removed from the index. If a directory given, adds the files and all his sub-directories recursively in the w
(path string)
| 270 | // the worktree to the index. If any of the files is already staged in the index |
| 271 | // no error is returned. When path is a file, the blob.Hash is returned. |
| 272 | func (w *Worktree) Add(path string) (plumbing.Hash, error) { |
| 273 | // TODO(mcuadros): deprecate in favor of AddWithOption in v6. |
| 274 | return w.doAdd(path, make([]gitignore.Pattern, 0), false) |
| 275 | } |
| 276 | |
| 277 | func (w *Worktree) doAddDirectory(idx *index.Index, s Status, directory string, ignorePattern []gitignore.Pattern) (added bool, err error) { |
| 278 | if len(ignorePattern) > 0 { |