| 558 | } |
| 559 | |
| 560 | func (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. |
| 584 | func (w *Worktree) Remove(path string) (plumbing.Hash, error) { |