Worktree returns a worktree based on the given fs, if nil the default worktree will be used.
()
| 1526 | // Worktree returns a worktree based on the given fs, if nil the default |
| 1527 | // worktree will be used. |
| 1528 | func (r *Repository) Worktree() (*Worktree, error) { |
| 1529 | if r.wt == nil { |
| 1530 | return nil, ErrIsBareRepository |
| 1531 | } |
| 1532 | |
| 1533 | protectNTFS := defaultProtectNTFS() |
| 1534 | protectHFS := defaultProtectHFS() |
| 1535 | if cfg, err := r.Config(); err == nil { |
| 1536 | if cfg.Core.ProtectNTFS.IsSet() { |
| 1537 | protectNTFS = cfg.Core.ProtectNTFS.IsTrue() |
| 1538 | } |
| 1539 | if cfg.Core.ProtectHFS.IsSet() { |
| 1540 | protectHFS = cfg.Core.ProtectHFS.IsTrue() |
| 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | return &Worktree{r: r, Filesystem: newWorktreeFilesystem(r.wt, protectNTFS, protectHFS)}, nil |
| 1545 | } |
| 1546 | |
| 1547 | func expand_ref(s storer.ReferenceStorer, ref plumbing.ReferenceName) (*plumbing.Reference, error) { |
| 1548 | // For improving troubleshooting, this preserves the error for the provided `ref`, |