@@ -556,12 +556,18 @@ impl Build {
556556 continue
557557 }
558558
559+ if !submodule. path . exists ( ) {
560+ t ! ( fs:: create_dir_all( & submodule. path) ) ;
561+ }
562+
559563 match submodule. state {
560564 State :: MaybeDirty => {
561565 // drop staged changes
562- self . run ( git ( ) . arg ( "-C" ) . arg ( submodule. path ) . args ( & [ "reset" , "--hard" ] ) ) ;
566+ self . run ( git ( ) . current_dir ( submodule. path )
567+ . args ( & [ "reset" , "--hard" ] ) ) ;
563568 // drops unstaged changes
564- self . run ( git ( ) . arg ( "-C" ) . arg ( submodule. path ) . args ( & [ "clean" , "-fdx" ] ) ) ;
569+ self . run ( git ( ) . current_dir ( submodule. path )
570+ . args ( & [ "clean" , "-fdx" ] ) ) ;
565571 } ,
566572 State :: NotInitialized => {
567573 self . run ( git_submodule ( ) . arg ( "init" ) . arg ( submodule. path ) ) ;
@@ -570,8 +576,10 @@ impl Build {
570576 State :: OutOfSync => {
571577 // drops submodule commits that weren't reported to the (outer) git repository
572578 self . run ( git_submodule ( ) . arg ( "update" ) . arg ( submodule. path ) ) ;
573- self . run ( git ( ) . arg ( "-C" ) . arg ( submodule. path ) . args ( & [ "reset" , "--hard" ] ) ) ;
574- self . run ( git ( ) . arg ( "-C" ) . arg ( submodule. path ) . args ( & [ "clean" , "-fdx" ] ) ) ;
579+ self . run ( git ( ) . current_dir ( submodule. path )
580+ . args ( & [ "reset" , "--hard" ] ) ) ;
581+ self . run ( git ( ) . current_dir ( submodule. path )
582+ . args ( & [ "clean" , "-fdx" ] ) ) ;
575583 } ,
576584 }
577585 }
0 commit comments