@@ -645,7 +645,7 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
645
645
init_vcs ( path, vcs, config) ?;
646
646
write_ignore_file ( path, & ignore, vcs) ?;
647
647
648
- let ( author_name, email) = discover_author ( ) ?;
648
+ let ( author_name, email) = discover_author ( path ) ?;
649
649
let author = match ( cfg. name , cfg. email , author_name, email) {
650
650
( Some ( name) , Some ( email) , _, _)
651
651
| ( Some ( name) , None , _, Some ( email) )
@@ -781,8 +781,8 @@ fn get_environment_variable(variables: &[&str]) -> Option<String> {
781
781
variables. iter ( ) . filter_map ( |var| env:: var ( var) . ok ( ) ) . next ( )
782
782
}
783
783
784
- fn discover_author ( ) -> CargoResult < ( String , Option < String > ) > {
785
- let git_config = find_git_config ( ) ;
784
+ fn discover_author ( path : & Path ) -> CargoResult < ( String , Option < String > ) > {
785
+ let git_config = find_git_config ( path ) ;
786
786
let git_config = git_config. as_ref ( ) ;
787
787
788
788
let name_variables = [
@@ -833,10 +833,10 @@ fn discover_author() -> CargoResult<(String, Option<String>)> {
833
833
Ok ( ( name, email) )
834
834
}
835
835
836
- fn find_git_config ( ) -> Option < GitConfig > {
836
+ fn find_git_config ( path : & Path ) -> Option < GitConfig > {
837
837
match env:: var ( "__CARGO_TEST_ROOT" ) {
838
838
Ok ( test_root) => find_tests_git_config ( test_root) ,
839
- Err ( _) => find_real_git_config ( ) ,
839
+ Err ( _) => find_real_git_config ( path ) ,
840
840
}
841
841
}
842
842
@@ -851,12 +851,9 @@ fn find_tests_git_config(cargo_test_root: String) -> Option<GitConfig> {
851
851
}
852
852
}
853
853
854
- fn find_real_git_config ( ) -> Option < GitConfig > {
855
- match env:: current_dir ( ) {
856
- Ok ( cwd) => GitRepository :: discover ( cwd)
857
- . and_then ( |repo| repo. config ( ) )
858
- . or_else ( |_| GitConfig :: open_default ( ) )
859
- . ok ( ) ,
860
- Err ( _) => GitConfig :: open_default ( ) . ok ( ) ,
861
- }
854
+ fn find_real_git_config ( path : & Path ) -> Option < GitConfig > {
855
+ GitRepository :: discover ( path)
856
+ . and_then ( |repo| repo. config ( ) )
857
+ . or_else ( |_| GitConfig :: open_default ( ) )
858
+ . ok ( )
862
859
}
0 commit comments