@@ -307,22 +307,20 @@ impl Path<'_> {
307307 const PREFIX : & [ u8 ] = b"%(prefix)/" ;
308308 const SLASH : u8 = b'/' ;
309309 if val. starts_with ( PREFIX ) {
310- let mut expanded = git_install_dir. ok_or ( ( ) ) ?. to_str ( ) . ok_or ( ( ) ) ?. as_bytes ( ) . to_owned ( ) ;
310+ let mut expanded = git_features:: path:: into_bytes ( git_install_dir. ok_or ( ( ) ) ?)
311+ . ok_or ( ( ) ) ?
312+ . into_owned ( ) ;
311313 let ( _prefix, val) = val. split_at ( PREFIX . len ( ) - 1 ) ;
312314 expanded. extend ( val) ;
313315 Ok ( Path {
314316 value : Cow :: Owned ( expanded) ,
315317 } )
316318 } else if val. starts_with ( b"~/" ) {
317- let home = dirs:: home_dir ( ) . ok_or ( ( ) ) ?. to_str ( ) . ok_or ( ( ) ) ?. to_owned ( ) ;
318- #[ cfg( target_os = "windows" ) ]
319- let mut home = home. replace ( "\\ " , "/" ) ;
320- let mut expanded = home. as_bytes ( ) . to_owned ( ) ;
319+ let mut expanded = dirs:: home_dir ( ) . ok_or ( ( ) ) ?. to_str ( ) . ok_or ( ( ) ) ?. as_bytes ( ) . to_owned ( ) ;
321320 let ( _prefix, val) = val. split_at ( SLASH . len ( ) ) ;
322321 expanded. extend ( val) ;
323- Ok ( Path {
324- value : Cow :: Owned ( expanded) ,
325- } )
322+ let expanded = git_features:: path:: convert:: to_native_separators ( expanded) ;
323+ Ok ( Path { value : expanded } )
326324 } else if val. starts_with ( b"~" ) && val. contains ( & SLASH ) {
327325 Self :: interpolate_user ( val, SLASH )
328326 } else {
@@ -331,7 +329,7 @@ impl Path<'_> {
331329 }
332330
333331 #[ cfg( target_os = "windows" ) ]
334- fn interpolate_user ( val : Cow < [ u8 ] > , slash : u8 ) -> Result < Path , ( ) > {
332+ fn interpolate_user ( _val : Cow < [ u8 ] > , _slash : u8 ) -> Result < Path , ( ) > {
335333 Err ( ( ) )
336334 }
337335
@@ -340,10 +338,8 @@ impl Path<'_> {
340338 let ( _prefix, val) = val. split_at ( slash. len ( ) ) ;
341339 let i = val. iter ( ) . position ( |& e| e == slash) . ok_or ( ( ) ) ?;
342340 let ( username, val) = val. split_at ( i) ;
343- let home = Passwd :: from_name ( std:: str:: from_utf8 ( username) . map_err ( |_| ( ) ) ?)
344- . map_err ( |_| ( ) ) ?
345- . ok_or ( ( ) ) ?
346- . dir ;
341+ let path = git_features:: path:: from_bytes ( username) . ok_or ( ( ) ) ?;
342+ let home = Passwd :: from_name ( path. to_str ( ) . ok_or ( ( ) ) ?) . map_err ( |_|( ) ) ?. ok_or ( ( ) ) ?. dir ;
347343 let mut expanded = home. as_bytes ( ) . to_owned ( ) ;
348344 expanded. extend ( val) ;
349345 Ok ( Path {
0 commit comments