From 9835e2ae736235810b4ea1c162ca5e65c547e770 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 18 May 2024 04:49:50 +0200 Subject: Merging upstream version 1.71.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/gix-path/src/convert.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'vendor/gix-path/src/convert.rs') diff --git a/vendor/gix-path/src/convert.rs b/vendor/gix-path/src/convert.rs index 6a949529f..d8bf70353 100644 --- a/vendor/gix-path/src/convert.rs +++ b/vendor/gix-path/src/convert.rs @@ -82,6 +82,16 @@ pub fn into_bstr<'a>(path: impl Into>) -> Cow<'a, BStr> { try_into_bstr(path).expect("prefix path doesn't contain ill-formed UTF-8") } +/// Join `path` to `base` such that they are separated with a `/`, i.e. `base/path`. +pub fn join_bstr_unix_pathsep<'a, 'b>(base: impl Into>, path: impl Into<&'b BStr>) -> Cow<'a, BStr> { + let mut base = base.into(); + if !base.is_empty() && base.last() != Some(&b'/') { + base.to_mut().push(b'/'); + } + base.to_mut().extend_from_slice(path.into()); + base +} + /// Given `input` bytes, produce a `Path` from them ignoring encoding entirely if on unix. /// /// On windows, the input is required to be valid UTF-8, which is guaranteed if we wrote it before. There are some potential -- cgit v1.2.3