MCPcopy Index your code
hub / github.com/go-git/go-git / AddWithOptions

Method AddWithOptions

worktree_status.go:335–351  ·  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

333// made to the working tree files applied, or remove paths that do not exist in
334// the working tree anymore.
335func (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
353func (w *Worktree) doAdd(path string, ignorePattern []gitignore.Pattern, skipStatus bool) (plumbing.Hash, error) {
354 idx, err := w.r.Storer.Index()

Calls 3

doAddMethod · 0.95
AddGlobMethod · 0.95
ValidateMethod · 0.45