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

Method doAddFileToIndex

worktree_status.go:548–558  ·  view source on GitHub ↗
(idx *index.Index, filename string, h plumbing.Hash)

Source from the content-addressed store, hash-verified

546}
547
548func (w *Worktree) doAddFileToIndex(idx *index.Index, filename string, h plumbing.Hash) error {
549 // Mirror upstream's Index.Add gate at the v5 caller boundary: the
550 // index feeds future trees, so a name that the tree-side
551 // pathutil.ValidTreePath gate would reject must not enter the
552 // index in the first place. v5 keeps Index.Add's existing signature
553 // for API compatibility, so the validation happens here.
554 if err := pathutil.ValidTreePath(filename); err != nil {
555 return err
556 }
557 return w.doUpdateFileToIndex(idx.Add(filename), filename, h)
558}
559
560func (w *Worktree) doUpdateFileToIndex(e *index.Entry, filename string, h plumbing.Hash) error {
561 info, err := w.Filesystem.Lstat(filename)

Callers 1

Calls 3

doUpdateFileToIndexMethod · 0.95
ValidTreePathFunction · 0.92
AddMethod · 0.45

Tested by

no test coverage detected