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

Method addOrUpdateFileToIndex

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

Source from the content-addressed store, hash-verified

533}
534
535func (w *Worktree) addOrUpdateFileToIndex(idx *index.Index, filename string, h plumbing.Hash) error {
536 e, err := idx.Entry(filename)
537 if err != nil && err != index.ErrEntryNotFound {
538 return err
539 }
540
541 if err == index.ErrEntryNotFound {
542 return w.doAddFileToIndex(idx, filename, h)
543 }
544
545 return w.doUpdateFileToIndex(e, filename, h)
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

Callers 2

doAddFileMethod · 0.95
MoveMethod · 0.95

Calls 3

doAddFileToIndexMethod · 0.95
doUpdateFileToIndexMethod · 0.95
EntryMethod · 0.80

Tested by

no test coverage detected