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)
| 287 | // the worktree to the index. If any of the files is already staged in the index |
| 288 | // no error is returned. When path is a file, the blob.Hash is returned. |
| 289 | func (w *Worktree) Add(path string) (plumbing.Hash, error) { |
| 290 | // TODO(mcuadros): deprecate in favor of AddWithOption in v6. |
| 291 | return w.doAdd(path, make([]gitignore.Pattern, 0), false) |
| 292 | } |
| 293 | |
| 294 | func (w *Worktree) doAddDirectory(idx *index.Index, s Status, directory string, ignorePattern []gitignore.Pattern) (added bool, err error) { |
| 295 | if len(ignorePattern) > 0 { |