| 704 | } |
| 705 | |
| 706 | func (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 | |
| 730 | func (r *Repository) getTreeFromCommitHash(commit plumbing.Hash) (*object.Tree, error) { |
| 731 | c, err := r.CommitObject(commit) |