@@ -41,6 +41,7 @@ use some of the helper functions in this file to interact with the repository.
41
41
use crate :: { path2url, project, Project , ProjectBuilder } ;
42
42
use std:: fs;
43
43
use std:: path:: { Path , PathBuf } ;
44
+ use std:: sync:: Once ;
44
45
use url:: Url ;
45
46
46
47
#[ must_use]
@@ -124,11 +125,25 @@ impl Repository {
124
125
125
126
/// Initialize a new repository at the given path.
126
127
pub fn init ( path : & Path ) -> git2:: Repository {
128
+ default_search_path ( ) ;
127
129
let repo = t ! ( git2:: Repository :: init( path) ) ;
128
130
default_repo_cfg ( & repo) ;
129
131
repo
130
132
}
131
133
134
+ fn default_search_path ( ) {
135
+ use crate :: paths:: GLOBAL_ROOT ;
136
+ use git2:: { opts:: set_search_path, ConfigLevel } ;
137
+ static INIT : Once = Once :: new ( ) ;
138
+ INIT . call_once ( || unsafe {
139
+ let path = GLOBAL_ROOT . join ( "blank_git_search_path" ) ;
140
+ t ! ( set_search_path( ConfigLevel :: System , & path) ) ;
141
+ t ! ( set_search_path( ConfigLevel :: Global , & path) ) ;
142
+ t ! ( set_search_path( ConfigLevel :: XDG , & path) ) ;
143
+ t ! ( set_search_path( ConfigLevel :: ProgramData , & path) ) ;
144
+ } )
145
+ }
146
+
132
147
fn default_repo_cfg ( repo : & git2:: Repository ) {
133
148
let mut cfg = t ! ( repo. config( ) ) ;
134
149
t ! ( cfg. set_str( "user.email" , "foo@bar.com" ) ) ;
0 commit comments