(path string)
| 114 | } |
| 115 | |
| 116 | func ensureWorktreePathSafe(path string) error { |
| 117 | fi, err := os.Lstat(path) |
| 118 | switch { |
| 119 | case os.IsNotExist(err): |
| 120 | return nil |
| 121 | case err != nil: |
| 122 | return err |
| 123 | case fi.Mode()&os.ModeSymlink != 0: |
| 124 | return fmt.Errorf("--worktree path must not be a symlink: %s", path) |
| 125 | case !fi.IsDir(): |
| 126 | return fmt.Errorf("--worktree path must be a directory: %s", path) |
| 127 | } |
| 128 | return nil |
| 129 | } |
| 130 | |
| 131 | func ensureWorktreePathEmpty(path string) error { |
| 132 | dir, err := os.Open(path) |
no test coverage detected