File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ description = "A crate of the gitoxide project dealing with 'git status'-like fu
99authors = [" Sebastian Thiel <sebastian.thiel@icloud.com>" , " Pascal Kuthe <pascal.kuthe@semimod.de>" ]
1010edition = " 2021"
1111include = [" src/**/*" , " LICENSE-*" ]
12- rust-version = " 1.70 "
12+ rust-version = " 1.74 "
1313autotests = false
1414
1515[lib ]
Original file line number Diff line number Diff line change 1- use std:: path:: { Path , PathBuf } ;
2-
1+ use bstr:: BStr ;
32use gix_fs:: Stack ;
3+ use std:: borrow:: Cow ;
4+ use std:: path:: { Path , PathBuf } ;
45
56use crate :: SymlinkCheck ;
67
@@ -27,6 +28,22 @@ impl SymlinkCheck {
2728 self . inner . make_relative_path_current ( relative_path, & mut Delegate ) ?;
2829 Ok ( self . inner . current ( ) )
2930 }
31+
32+ /// Like [`Self::verified_path()`], but do not fail if there is no directory entry at `relative_path` or on the way
33+ /// to `relative_path`. Instead.
34+ /// For convenience, this incarnation is tuned to be easy to use with Git paths, i.e. slash-separated `BString` path.
35+ pub fn verified_path_allow_nonexisting ( & mut self , relative_path : & BStr ) -> std:: io:: Result < Cow < ' _ , Path > > {
36+ let rela_path = gix_path:: try_from_bstr ( relative_path) . map_err ( std:: io:: Error :: other) ?;
37+ if let Err ( err) = self . verified_path ( & rela_path) {
38+ if err. kind ( ) == std:: io:: ErrorKind :: NotFound {
39+ Ok ( Cow :: Owned ( self . inner . root ( ) . join ( rela_path) ) )
40+ } else {
41+ Err ( err)
42+ }
43+ } else {
44+ Ok ( Cow :: Borrowed ( self . inner . current ( ) ) )
45+ }
46+ }
3047}
3148
3249struct Delegate ;
You can’t perform that action at this time.
0 commit comments