WithRoot places the worktree under dir instead of the default data directory. The worktree is created at /worktrees/ . An empty dir is ignored, keeping the default. This decouples the package from the process-global data directory, letting tests and embedders pick an isolated location.
(dir string)
| 106 | // process-global data directory, letting tests and embedders pick an isolated |
| 107 | // location. |
| 108 | func WithRoot(dir string) CreateOption { |
| 109 | return func(c *createConfig) { |
| 110 | if dir != "" { |
| 111 | c.root = dir |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // Create creates a new git worktree for the repository containing dir and |
| 117 | // returns it. The worktree lives under the data directory and checks out a |
no outgoing calls