MCPcopy Create free account
hub / github.com/go-git/go-git / AddWithOptions

Method AddWithOptions

worktree_status.go:318–334  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

316// made to the working tree files applied, or remove paths that do not exist in
317// the working tree anymore.
318func (w *Worktree) AddWithOptions(opts *AddOptions) error {
319 if err := opts.Validate(w.r); err != nil {
320 return err
321 }
322
323 if opts.All {
324 _, err := w.doAdd(".", w.Excludes, false)
325 return err
326 }
327
328 if opts.Glob != "" {
329 return w.AddGlob(opts.Glob)
330 }
331
332 _, err := w.doAdd(opts.Path, make([]gitignore.Pattern, 0), opts.SkipStatus)
333 return err
334}
335
336func (w *Worktree) doAdd(path string, ignorePattern []gitignore.Pattern, skipStatus bool) (plumbing.Hash, error) {
337 idx, err := w.r.Storer.Index()

Calls 3

doAddMethod · 0.95
AddGlobMethod · 0.95
ValidateMethod · 0.45