MCPcopy
hub / github.com/go-git/go-git / Add

Method Add

worktree_status.go:289–292  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
289func (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
294func (w *Worktree) doAddDirectory(idx *index.Index, s Status, directory string, ignorePattern []gitignore.Pattern) (added bool, err error) {
295 if len(ignorePattern) > 0 {

Calls 1

doAddMethod · 0.95

Tested by 15

TestCheckoutKeepMethod · 0.76
TestAddUntrackedMethod · 0.76
TestAddModifiedMethod · 0.76
TestAddUnmodifiedMethod · 0.76
TestAddRemovedMethod · 0.76
TestAddDirectoryMethod · 0.76