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

Method Add

worktree_status.go:272–275  ·  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

270// the worktree to the index. If any of the files is already staged in the index
271// no error is returned. When path is a file, the blob.Hash is returned.
272func (w *Worktree) Add(path string) (plumbing.Hash, error) {
273 // TODO(mcuadros): deprecate in favor of AddWithOption in v6.
274 return w.doAdd(path, make([]gitignore.Pattern, 0), false)
275}
276
277func (w *Worktree) doAddDirectory(idx *index.Index, s Status, directory string, ignorePattern []gitignore.Pattern) (added bool, err error) {
278 if len(ignorePattern) > 0 {

Callers 15

TestCheckoutKeepMethod · 0.95
TestAddUntrackedMethod · 0.95
TestAddModifiedMethod · 0.95
TestAddUnmodifiedMethod · 0.95
TestAddRemovedMethod · 0.95
TestAddDirectoryMethod · 0.95
TestCommitParentMethod · 0.95

Calls 1

doAddMethod · 0.95

Tested by 14

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