Resolves the filesystem root of the worktree created by a `git worktree add` command. git resolves the worktree path against `-C `/`--work-tree` overrides rather than the shell cwd, so those are honored first. The result is canonicalized when the worktree exists (it does by the time a post-shell hook fires) so symlinked components resolve the way git resolved them, falling back to lexical `..
(command: &str, cwd: &Path, worktree_path: &str)
| 357 | /// does by the time a post-shell hook fires) so symlinked components resolve |
| 358 | /// the way git resolved them, falling back to lexical `..` normalization. |
| 359 | pub fn resolve_worktree_add_root(command: &str, cwd: &Path, worktree_path: &str) -> PathBuf { |
| 360 | let tokens = shell_words(command); |
| 361 | let base = git_explicit_work_dir(&tokens, cwd).unwrap_or_else(|| cwd.to_path_buf()); |
| 362 | let joined = resolve_shell_path(&base, worktree_path); |
| 363 | joined |
| 364 | .canonicalize() |
| 365 | .unwrap_or_else(|_| normalize_lexically(&joined)) |
| 366 | } |
| 367 | |
| 368 | fn normalize_lexically(path: &Path) -> PathBuf { |
| 369 | let mut normalized = PathBuf::new(); |
no test coverage detected