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

Method checkoutFile

worktree.go:629–656  ·  view source on GitHub ↗
(f *object.File)

Source from the content-addressed store, hash-verified

627}
628
629func (w *Worktree) checkoutFile(f *object.File) (err error) {
630 mode, err := f.Mode.ToOSFileMode()
631 if err != nil {
632 return
633 }
634
635 if mode&os.ModeSymlink != 0 {
636 return w.checkoutFileSymlink(f)
637 }
638
639 from, err := f.Reader()
640 if err != nil {
641 return
642 }
643
644 defer ioutil.CheckClose(from, &err)
645
646 to, err := w.Filesystem.OpenFile(f.Name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, mode.Perm())
647 if err != nil {
648 return
649 }
650
651 defer ioutil.CheckClose(to, &err)
652 buf := sync.GetByteSlice()
653 _, err = io.CopyBuffer(to, from, *buf)
654 sync.PutByteSlice(buf)
655 return
656}
657
658func (w *Worktree) checkoutFileSymlink(f *object.File) (err error) {
659 // .gitmodules symlink rejection (and its NTFS / HFS variants) is

Callers 1

Calls 7

checkoutFileSymlinkMethod · 0.95
CheckCloseFunction · 0.92
GetByteSliceFunction · 0.92
PutByteSliceFunction · 0.92
ToOSFileModeMethod · 0.80
ReaderMethod · 0.65
OpenFileMethod · 0.45

Tested by

no test coverage detected