@@ -82,17 +82,19 @@ fn download_deps()
8282 println ! ( "Number of submodules: {}" , submodules. len( ) ) ;
8383
8484 // Prevent shitty error case since the libgit2 sdk sucks. (This bug is present in the C version of the API as well)
85- let mut file = match File :: open ( ".git/config" )
86- {
87- Ok ( file) => file,
88- Err ( e) => panic ! ( "Failed to open .git/config file: {}" , e) ,
89- } ;
9085 let mut contents = String :: new ( ) ;
91- match file. read_to_string ( & mut contents)
9286 {
93- Ok ( contents) => contents,
94- Err ( e) => panic ! ( "Failed to read from .git/config file: {}" , e) ,
95- } ;
87+ let mut file = match File :: open ( ".git/config" )
88+ {
89+ Ok ( file) => file,
90+ Err ( e) => panic ! ( "Failed to open .git/config file: {}" , e) ,
91+ } ;
92+ match file. read_to_string ( & mut contents)
93+ {
94+ Ok ( contents) => contents,
95+ Err ( e) => panic ! ( "Failed to read from .git/config file: {}" , e) ,
96+ } ;
97+ }
9698
9799 // Init and Update Submodules.
98100 for mut submodule in submodules {
@@ -112,17 +114,20 @@ fn download_deps()
112114
113115 if !cfp. exists ( )
114116 {
115- println ! ( "Detected already inialized submodule {}" , submodule. name( ) . unwrap( ) ) ;
116- println ! ( "Making sure the deps/[submodule] dir is valid to prevent bug in libgit2." ) ;
117-
118- let mut file = match File :: create ( cfp)
117+ if Path :: new ( & format ! ( "gitdir: ../../.git/modules/{}" , submodule. path( ) . display( ) ) ) . exists ( )
119118 {
120- Ok ( file) => { println ! ( "Wrote .git file for {}" , submodule. name( ) . unwrap( ) ) ; file } ,
121- Err ( e) => panic ! ( "Failed to create .git file for submodule: {}" , e) ,
122- } ;
123-
124- let newcontent = & format ! ( "gitdir: ../../.git/modules/{}" , submodule. path( ) . display( ) ) ;
125- file. write_all ( newcontent. as_bytes ( ) ) . unwrap ( ) ;
119+ println ! ( "Detected already inialized submodule {}" , submodule. name( ) . unwrap( ) ) ;
120+ println ! ( "Making sure the deps/[submodule] dir is valid to prevent bug in libgit2." ) ;
121+
122+ let mut file = match File :: create ( cfp)
123+ {
124+ Ok ( file) => { println ! ( "Wrote .git file for {}" , submodule. name( ) . unwrap( ) ) ; file } ,
125+ Err ( e) => panic ! ( "Failed to create .git file for submodule: {}" , e) ,
126+ } ;
127+
128+ let newcontent = & format ! ( "gitdir: ../../.git/modules/{}" , submodule. path( ) . display( ) ) ;
129+ file. write_all ( newcontent. as_bytes ( ) ) . unwrap ( ) ;
130+ }
126131 }
127132 }
128133
0 commit comments