From 8df04d8973fc62eae0e8d98c8116351907dd282f Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 9 Aug 2021 13:27:38 +0800 Subject: [PATCH] [ref #152] no silent failure if path conversion isn't possible For now we are loud about it for the lack of a better way to do certain transformations on windows. The API remains the same though, assuming that eventually we will do some rewriting and possibly return a PathBuf instead, hence 'Cow'. --- git-ref/src/mutable.rs | 2 +- git-ref/src/name.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/git-ref/src/mutable.rs b/git-ref/src/mutable.rs index 22feb72a4bc..4a712e447b4 100644 --- a/git-ref/src/mutable.rs +++ b/git-ref/src/mutable.rs @@ -52,7 +52,7 @@ impl FullName { /// Convert this name into the relative path, lossily, identifying the reference location relative to a repository pub fn to_path(&self) -> Cow<'_, Path> { - self.0.to_path_lossy() + self.0.to_path().expect("UTF-8 conversion always succeeds").into() } /// Dissolve this instance and return the buffer. diff --git a/git-ref/src/name.rs b/git-ref/src/name.rs index 60835063672..6179f819bd1 100644 --- a/git-ref/src/name.rs +++ b/git-ref/src/name.rs @@ -8,7 +8,7 @@ pub type Error = git_validate::reference::name::Error; impl<'a> FullName<'a> { /// Convert this name into the relative path identifying the reference location. pub fn to_path(self) -> Cow<'a, Path> { - self.0.to_path_lossy() + self.0.to_path().expect("UTF-8 conversion always succeeds").into() } /// Return ourselves as byte string which is a valid refname @@ -21,7 +21,7 @@ impl<'a> PartialName<'a> { /// Convert this name into the relative path possibly identifying the reference location. /// Note that it may be only a partial path though. pub fn to_partial_path(self) -> Cow<'a, Path> { - self.0.to_path_lossy() + self.0.to_path().expect("UTF-8 conversion always succeeds").into() } /// Provide the name as binary string which is known to be a valid partial ref name.