AddWithOptions file contents to the index, updates the index using the current content found in the working tree, to prepare the content staged for the next commit. It typically adds the current content of existing paths as a whole, but with some options it can also be used to add content with onl
(opts *AddOptions)
| 333 | // made to the working tree files applied, or remove paths that do not exist in |
| 334 | // the working tree anymore. |
| 335 | func (w *Worktree) AddWithOptions(opts *AddOptions) error { |
| 336 | if err := opts.Validate(w.r); err != nil { |
| 337 | return err |
| 338 | } |
| 339 | |
| 340 | if opts.All { |
| 341 | _, err := w.doAdd(".", w.Excludes, false) |
| 342 | return err |
| 343 | } |
| 344 | |
| 345 | if opts.Glob != "" { |
| 346 | return w.AddGlob(opts.Glob) |
| 347 | } |
| 348 | |
| 349 | _, err := w.doAdd(opts.Path, make([]gitignore.Pattern, 0), opts.SkipStatus) |
| 350 | return err |
| 351 | } |
| 352 | |
| 353 | func (w *Worktree) doAdd(path string, ignorePattern []gitignore.Pattern, skipStatus bool) (plumbing.Hash, error) { |
| 354 | idx, err := w.r.Storer.Index() |