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

Method addOrUpdateFileToIndex

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

Source from the content-addressed store, hash-verified

514}
515
516func (w *Worktree) addOrUpdateFileToIndex(idx *index.Index, filename string, h plumbing.Hash) error {
517 e, err := idx.Entry(filename)
518 if err != nil && err != index.ErrEntryNotFound {
519 return err
520 }
521
522 if err == index.ErrEntryNotFound {
523 return w.doAddFileToIndex(idx, filename, h)
524 }
525
526 return w.doUpdateFileToIndex(e, filename, h)
527}
528
529func (w *Worktree) doAddFileToIndex(idx *index.Index, filename string, h plumbing.Hash) error {
530 return w.doUpdateFileToIndex(idx.Add(filename), filename, h)

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