(f *object.File)
| 678 | } |
| 679 | |
| 680 | func (w *Worktree) checkoutFileSymlink(f *object.File) (err error) { |
| 681 | // https://github.com/git/git/commit/10ecfa76491e4923988337b2e2243b05376b40de |
| 682 | if strings.EqualFold(f.Name, gitmodulesFile) { |
| 683 | return ErrGitModulesSymlink |
| 684 | } |
| 685 | |
| 686 | from, err := f.Reader() |
| 687 | if err != nil { |
| 688 | return |
| 689 | } |
| 690 | |
| 691 | defer ioutil.CheckClose(from, &err) |
| 692 | |
| 693 | bytes, err := io.ReadAll(from) |
| 694 | if err != nil { |
| 695 | return |
| 696 | } |
| 697 | |
| 698 | err = w.Filesystem.Symlink(string(bytes), f.Name) |
| 699 | |
| 700 | // On windows, this might fail. |
| 701 | // Follow Git on Windows behavior by writing the link as it is. |
| 702 | if err != nil && isSymlinkWindowsNonAdmin(err) { |
| 703 | mode, _ := f.Mode.ToOSFileMode() |
| 704 | |
| 705 | to, err := w.Filesystem.OpenFile(f.Name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, mode.Perm()) |
| 706 | if err != nil { |
| 707 | return err |
| 708 | } |
| 709 | |
| 710 | defer ioutil.CheckClose(to, &err) |
| 711 | |
| 712 | _, err = to.Write(bytes) |
| 713 | return err |
| 714 | } |
| 715 | return |
| 716 | } |
| 717 | |
| 718 | func (w *Worktree) addIndexFromTreeEntry(name string, f *object.TreeEntry, idx *indexBuilder) error { |
| 719 | idx.Remove(name) |
no test coverage detected