diff options
Diffstat (limited to 'src/worktree.rs')
| -rw-r--r-- | src/worktree.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/worktree.rs b/src/worktree.rs index 058ee2b8..8c1d40bb 100644 --- a/src/worktree.rs +++ b/src/worktree.rs @@ -68,6 +68,17 @@ pub(crate) fn expand_tilde_path(path: &str) -> PathBuf { PathBuf::from(path) } +pub(crate) fn expand_tilde_absolute_path(path: &str) -> PathBuf { + let path = expand_tilde_path(path); + if path.is_absolute() { + path + } else { + std::env::current_dir() + .map(|cwd| cwd.join(&path)) + .unwrap_or(path) + } +} + pub(crate) fn canonical_or_original(path: &Path) -> PathBuf { std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf()) } |
