@@ -247,16 +247,34 @@ pub fn to_windows_separators<'a>(path: impl Into<Cow<'a, BStr>>) -> Cow<'a, BStr
247
247
///
248
248
/// For example, this turns `a/./b/c/.././..` into `a`, and turns `/a/../b/..` into `/`.
249
249
///
250
- /// If the input path was relative and ends up being the `current_dir`, `.` is returned instead of
251
- /// the full path to `current_dir`.
250
+ /// ```
251
+ /// # fn main() {
252
+ /// # use std::path::Path;
253
+ /// # use gix_path::normalize;
254
+ /// for (input, expected) in [
255
+ /// ("a/./b/c/.././..", "a"),
256
+ /// ("/a/../b/..", "/"),
257
+ /// ("/base/a/..", "/base"),
258
+ /// ("./a/..", "."),
259
+ /// ("./a/../..", "/"),
260
+ /// (".///", ".///"),
261
+ /// ("a//b", "a//b"),
262
+ /// ("/base/../base", "/base"),
263
+ /// ] {
264
+ /// let input = Path::new(input);
265
+ /// let expected = Path::new(expected);
266
+ /// assert_eq!(normalize(input.into(), Path::new("/cwd")), Some(expected.into()));
267
+ /// }
268
+ /// # }
269
+ /// ```
252
270
///
253
- /// Single `.` components as well as duplicate separators are left untouched.
271
+ /// Leading `.` components as well as duplicate separators are left untouched.
254
272
///
255
273
/// This is particularly useful when manipulating paths that are based on user input, and not
256
274
/// resolving intermediate symlinks keeps the path similar to what the user provided. If that's not
257
- /// desirable, use `[ realpath()][ crate::realpath()` instead.
275
+ /// desirable, use [` realpath()`]( crate::realpath()) instead.
258
276
///
259
- /// Note that we might access the `current_dir` if we run out of path components to pop off, which
277
+ /// Note that we will use the `current_dir` if we run out of path components to pop off, which
260
278
/// is expected to be absolute as typical return value of `std::env::current_dir()` or
261
279
/// `gix_fs::current_dir(…)` when `core.precomposeUnicode` is known. As a `current_dir` like `/c`
262
280
/// can be exhausted by paths like `../../r`, `None` will be returned to indicate the inability to
0 commit comments