Unified · Split
| @@ -157,7 +157,7 @@ pub(crate) mod function { · 156 unmodified lines | ||
| 157 | 157 | match filter_by_trust(&cursor)? { |
| 158 | 158 | Some(trust) => { |
| 159 | 159 | // TODO: test this more, it definitely doesn't find the shortest path to a directory |
| 160 | − let path = if dir_made_absolute { | |
| 160 | + let path = if dir_made_absolute && !directory.as_ref().is_absolute() { | |
| 161 | 161 | shorten_path_with_cwd(cursor, cwd) |
| 162 | 162 | } else { |
| 163 | 163 | cursor |
| @@ -259,6 +259,21 @@ fn cross_fs() -> crate::Result { · 258 unmodified lines | ||
| 259 | 259 | Ok(()) |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | +#[test] | |
| 263 | +fn do_not_shorten_absolute_paths() -> crate::Result { | |
| 264 | + let top_level_repo = repo_path()?.canonicalize().expect("repo path exists"); | |
| 265 | + let (repo_path, _trust) = git_discover::upwards(top_level_repo).expect("we can discover the repo"); | |
| 266 | + | |
| 267 | + match repo_path { | |
| 268 | + git_discover::repository::Path::WorkTree(work_dir) => { | |
| 269 | + assert!(work_dir.is_absolute()); | |
| 270 | + } | |
| 271 | + _ => panic!("expected worktree path"), | |
| 272 | + }; | |
| 273 | + | |
| 274 | + Ok(()) | |
| 275 | +} | |
| 276 | + | |
| 262 | 277 | fn repo_path() -> crate::Result<PathBuf> { |
| 263 | 278 | git_testtools::scripted_fixture_repo_read_only("make_basic_repo.sh") |
| 264 | 279 | } |