@@ -146,7 +146,7 @@ impl GitRemote {
146
146
paths:: remove_dir_all ( dst) ?;
147
147
}
148
148
fs:: create_dir_all ( dst) ?;
149
- let mut repo = git2 :: Repository :: init_bare ( dst) ?;
149
+ let mut repo = init ( dst, true ) ?;
150
150
fetch (
151
151
& mut repo,
152
152
& self . url ,
@@ -385,7 +385,7 @@ impl<'a> GitCheckout<'a> {
385
385
Err ( ..) => {
386
386
let path = parent. workdir ( ) . unwrap ( ) . join ( child. path ( ) ) ;
387
387
let _ = paths:: remove_dir_all ( & path) ;
388
- git2 :: Repository :: init ( & path) ?
388
+ init ( & path, false ) ?
389
389
}
390
390
} ;
391
391
@@ -833,7 +833,7 @@ fn reinitialize(repo: &mut git2::Repository) -> CargoResult<()> {
833
833
debug ! ( "reinitializing git repo at {:?}" , path) ;
834
834
let tmp = path. join ( "tmp" ) ;
835
835
let bare = !repo. path ( ) . ends_with ( ".git" ) ;
836
- * repo = git2 :: Repository :: init ( & tmp) ?;
836
+ * repo = init ( & tmp, false ) ?;
837
837
for entry in path. read_dir ( ) ? {
838
838
let entry = entry?;
839
839
if entry. file_name ( ) . to_str ( ) == Some ( "tmp" ) {
@@ -842,15 +842,21 @@ fn reinitialize(repo: &mut git2::Repository) -> CargoResult<()> {
842
842
let path = entry. path ( ) ;
843
843
drop ( paths:: remove_file ( & path) . or_else ( |_| paths:: remove_dir_all ( & path) ) ) ;
844
844
}
845
- if bare {
846
- * repo = git2:: Repository :: init_bare ( path) ?;
847
- } else {
848
- * repo = git2:: Repository :: init ( path) ?;
849
- }
845
+ * repo = init ( & path, bare) ?;
850
846
paths:: remove_dir_all ( & tmp) ?;
851
847
Ok ( ( ) )
852
848
}
853
849
850
+ fn init ( path : & Path , bare : bool ) -> CargoResult < git2:: Repository > {
851
+ let mut opts = git2:: RepositoryInitOptions :: new ( ) ;
852
+ // Skip anyting related to templates, they just call all sorts of issues as
853
+ // we really don't want to use them yet they insist on being used. See #6240
854
+ // for an example issue that comes up.
855
+ opts. external_template ( false ) ;
856
+ opts. bare ( bare) ;
857
+ Ok ( git2:: Repository :: init_opts ( & path, & opts) ?)
858
+ }
859
+
854
860
/// Updating the index is done pretty regularly so we want it to be as fast as
855
861
/// possible. For registries hosted on GitHub (like the crates.io index) there's
856
862
/// a fast path available to use [1] to tell us that there's no updates to be
0 commit comments