(worktree: &Path, input: &Path)
| 264 | } |
| 265 | |
| 266 | fn relative_to_worktree(worktree: &Path, input: &Path) -> String { |
| 267 | if input.is_absolute() { |
| 268 | input |
| 269 | .strip_prefix(worktree) |
| 270 | .ok() |
| 271 | .map(|p| p.to_string_lossy().to_string()) |
| 272 | .unwrap_or_default() |
| 273 | } else { |
| 274 | input.to_string_lossy().to_string() |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | #[cfg(test)] |
| 279 | mod tests { |