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

Method addIndexFromFile

worktree.go:728–755  ·  view source on GitHub ↗
(name string, h plumbing.Hash, idx *indexBuilder)

Source from the content-addressed store, hash-verified

726}
727
728func (w *Worktree) addIndexFromFile(name string, h plumbing.Hash, idx *indexBuilder) error {
729 idx.Remove(name)
730 fi, err := w.Filesystem.Lstat(name)
731 if err != nil {
732 return err
733 }
734
735 mode, err := filemode.NewFromOSFileMode(fi.Mode())
736 if err != nil {
737 return err
738 }
739
740 e := &index.Entry{
741 Hash: h,
742 Name: name,
743 Mode: mode,
744 ModifiedAt: fi.ModTime(),
745 Size: uint32(fi.Size()),
746 }
747
748 // if the FileInfo.Sys() comes from os the ctime, dev, inode, uid and gid
749 // can be retrieved, otherwise this doesn't apply
750 if fillSystemInfo != nil {
751 fillSystemInfo(e, fi.Sys())
752 }
753 idx.Add(e)
754 return nil
755}
756
757func (r *Repository) getTreeFromCommitHash(commit plumbing.Hash) (*object.Tree, error) {
758 c, err := r.CommitObject(commit)

Callers 1

Calls 6

NewFromOSFileModeFunction · 0.92
LstatMethod · 0.80
ModeMethod · 0.65
SizeMethod · 0.65
RemoveMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected