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

Method doUpdateFileToIndex

worktree_status.go:560–581  ·  view source on GitHub ↗
(e *index.Entry, filename string, h plumbing.Hash)

Source from the content-addressed store, hash-verified

558}
559
560func (w *Worktree) doUpdateFileToIndex(e *index.Entry, filename string, h plumbing.Hash) error {
561 info, err := w.Filesystem.Lstat(filename)
562 if err != nil {
563 return err
564 }
565
566 e.Hash = h
567 e.ModifiedAt = info.ModTime()
568 e.Mode, err = filemode.NewFromOSFileMode(info.Mode())
569 if err != nil {
570 return err
571 }
572
573 // The entry size must always reflect the current state, otherwise
574 // it will cause go-git's Worktree.Status() to divert from "git status".
575 // The size of a symlink is the length of the path to the target.
576 // The size of Regular and Executable files is the size of the files.
577 e.Size = uint32(info.Size())
578
579 fillSystemInfo(e, info.Sys())
580 return nil
581}
582
583// Remove removes files from the working tree and from the index.
584func (w *Worktree) Remove(path string) (plumbing.Hash, error) {

Callers 2

doAddFileToIndexMethod · 0.95

Calls 6

NewFromOSFileModeFunction · 0.92
ModTimeMethod · 0.80
SysMethod · 0.80
ModeMethod · 0.65
SizeMethod · 0.65
LstatMethod · 0.45

Tested by

no test coverage detected