File tree Expand file tree Collapse file tree 2 files changed +25
-10
lines changed
Expand file tree Collapse file tree 2 files changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,6 @@ shell-words = "1.0"
2424
2525[dev-dependencies ]
2626gix-testtools = { path = " ../tests/tools" }
27+
28+ [target .'cfg(not(unix))' .dev-dependencies ]
2729os_str_bytes = { version = " ^6.6.1" , default-features = false , features = [" conversions" ] }
Original file line number Diff line number Diff line change @@ -568,16 +568,22 @@ mod spawn {
568568 use os_str_bytes:: OsStringBytes ;
569569
570570 fn script_path ( filename : impl AsRef < Path > ) -> crate :: Result < OsString > {
571- // TODO(msrv): At 1.74, change into_raw_vec to into_encoded_bytes and don't depend on os_str_bytes.
572- let native_path: BString = gix_testtools:: scripted_fixture_read_only ( "scripts.sh" ) ?
571+ let native_path = gix_testtools:: scripted_fixture_read_only ( "scripts.sh" ) ?
573572 . join ( filename)
574- . into_os_string ( )
575- . into_raw_vec ( )
576- . into ( ) ;
577- let unix_path = gix_path:: to_unix_separators_on_windows ( native_path)
578- . to_os_str ( ) ?
579- . to_owned ( ) ;
580- Ok ( unix_path)
573+ . into_os_string ( ) ;
574+ #[ cfg( unix) ]
575+ {
576+ Ok ( native_path)
577+ }
578+ #[ cfg( not( unix) ) ]
579+ {
580+ // TODO(msrv): At 1.74, change into_raw_vec to into_encoded_bytes and don't depend on os_str_bytes.
581+ let raw_native_path: BString = native_path. into_raw_vec ( ) . into ( ) ;
582+ let slash_path = gix_path:: to_unix_separators_on_windows ( raw_native_path)
583+ . to_os_str ( ) ?
584+ . to_owned ( ) ;
585+ Ok ( slash_path)
586+ }
581587 }
582588
583589 fn script_stdout (
@@ -601,7 +607,14 @@ mod spawn {
601607 }
602608
603609 fn concatenate ( prefix : OsString , suffix : & str ) -> BString {
604- // TODO(msrv): At 1.74, change into_raw_vec to into_encoded_bytes and don't depend on os_str_bytes.
610+ // TODO(msrv): At 1.74, use into_encoded_bytes instead of into_vec and into_raw_vec,
611+ // and don't depend on os_str_bytes.
612+ #[ cfg( unix) ]
613+ let mut buffer: BString = {
614+ use std:: os:: unix:: ffi:: OsStringExt ;
615+ prefix. into_vec ( ) . into ( )
616+ } ;
617+ #[ cfg( not( unix) ) ]
605618 let mut buffer: BString = prefix. into_raw_vec ( ) . into ( ) ;
606619 buffer. push_str ( suffix) ;
607620 buffer
You can’t perform that action at this time.
0 commit comments