@@ -645,7 +645,7 @@ fn mk(config: &Config, opts: &MkOptions<'_>) -> CargoResult<()> {
645645 init_vcs ( path, vcs, config) ?;
646646 write_ignore_file ( path, & ignore, vcs) ?;
647647
648- let ( author_name, email) = discover_author ( ) ?;
648+ let ( author_name, email) = discover_author ( path ) ?;
649649 let author = match ( cfg. name , cfg. email , author_name, email) {
650650 ( Some ( name) , Some ( email) , _, _)
651651 | ( Some ( name) , None , _, Some ( email) )
@@ -781,8 +781,8 @@ fn get_environment_variable(variables: &[&str]) -> Option<String> {
781781 variables. iter ( ) . filter_map ( |var| env:: var ( var) . ok ( ) ) . next ( )
782782}
783783
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 ) ;
786786 let git_config = git_config. as_ref ( ) ;
787787
788788 let name_variables = [
@@ -833,10 +833,10 @@ fn discover_author() -> CargoResult<(String, Option<String>)> {
833833 Ok ( ( name, email) )
834834}
835835
836- fn find_git_config ( ) -> Option < GitConfig > {
836+ fn find_git_config ( path : & Path ) -> Option < GitConfig > {
837837 match env:: var ( "__CARGO_TEST_ROOT" ) {
838838 Ok ( test_root) => find_tests_git_config ( test_root) ,
839- Err ( _) => find_real_git_config ( ) ,
839+ Err ( _) => find_real_git_config ( path ) ,
840840 }
841841}
842842
@@ -851,12 +851,9 @@ fn find_tests_git_config(cargo_test_root: String) -> Option<GitConfig> {
851851 }
852852}
853853
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 ( )
862859}
0 commit comments