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

Method addIndexFromFile

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

Source from the content-addressed store, hash-verified

704}
705
706func (w *Worktree) addIndexFromFile(name string, h plumbing.Hash, mode filemode.FileMode, idx *indexBuilder) error {
707 idx.Remove(name)
708 fi, err := w.Filesystem.Lstat(name)
709 if err != nil {
710 return err
711 }
712
713 e := &index.Entry{
714 Hash: h,
715 Name: name,
716 Mode: mode,
717 ModifiedAt: fi.ModTime(),
718 Size: uint32(fi.Size()),
719 }
720
721 // if the FileInfo.Sys() comes from os the ctime, dev, inode, uid and gid
722 // can be retrieved, otherwise this doesn't apply
723 if fillSystemInfo != nil {
724 fillSystemInfo(e, fi.Sys())
725 }
726 idx.Add(e)
727 return nil
728}
729
730func (r *Repository) getTreeFromCommitHash(commit plumbing.Hash) (*object.Tree, error) {
731 c, err := r.CommitObject(commit)

Callers 1

Calls 6

ModTimeMethod · 0.80
SysMethod · 0.80
SizeMethod · 0.65
RemoveMethod · 0.45
LstatMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected