@@ -41,6 +41,7 @@ use some of the helper functions in this file to interact with the repository.
4141use crate :: { path2url, project, Project , ProjectBuilder } ;
4242use std:: fs;
4343use std:: path:: { Path , PathBuf } ;
44+ use std:: sync:: Once ;
4445use url:: Url ;
4546
4647#[ must_use]
@@ -124,11 +125,25 @@ impl Repository {
124125
125126/// Initialize a new repository at the given path.
126127pub fn init ( path : & Path ) -> git2:: Repository {
128+ default_search_path ( ) ;
127129 let repo = t ! ( git2:: Repository :: init( path) ) ;
128130 default_repo_cfg ( & repo) ;
129131 repo
130132}
131133
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+
132147fn default_repo_cfg ( repo : & git2:: Repository ) {
133148 let mut cfg = t ! ( repo. config( ) ) ;
134149 t ! ( cfg. set_str( "user.email" , "foo@bar.com" ) ) ;
0 commit comments