@@ -603,7 +603,7 @@ fn configure_command<'a>(
603603 . env_remove ( "GIT_ASKPASS" )
604604 . env_remove ( "SSH_ASKPASS" )
605605 . env ( "MSYS" , msys_for_git_bash_on_windows)
606- . env ( "GIT_CONFIG_SYSTEM " , NULL_DEVICE )
606+ . env ( "GIT_CONFIG_NOSYSTEM " , "1" )
607607 . env ( "GIT_CONFIG_GLOBAL" , NULL_DEVICE )
608608 . env ( "GIT_TERMINAL_PROMPT" , "false" )
609609 . env ( "GIT_AUTHOR_DATE" , "2000-01-01 00:00:00 +0000" )
@@ -898,43 +898,38 @@ mod tests {
898898 } else {
899899 & [ dir. join ( SCOPE_ENV_VALUE ) , dir. join ( "-" ) , dir. join ( ":" ) ]
900900 } ;
901-
902901 // Create the files.
903902 for path in paths {
904903 std:: fs:: write ( path, CONFIG_DATA ) . expect ( "can write contents" ) ;
905904 }
906-
907905 // Verify the files. This is mostly to show we really made a `\\?\...\NUL` on Windows.
908906 for path in paths {
909907 let buf = std:: fs:: read ( path) . expect ( "the file really exists" ) ;
910- assert_eq ! ( buf, CONFIG_DATA , "File {path:?} should be created " ) ;
908+ assert_eq ! ( buf, CONFIG_DATA , "{path:?} should be a config file " ) ;
911909 }
912910 }
913911
914- fn check_configure_clears_scope ( scope_env_key : & str , scope_option : & str ) {
912+ #[ test]
913+ fn configure_command_clears_external_config ( ) {
915914 let temp = tempfile:: TempDir :: new ( ) . expect ( "can create temp dir" ) ;
916- let dir = temp. path ( ) ;
917- populate_ad_hoc_config_files ( dir) ;
915+ populate_ad_hoc_config_files ( temp. path ( ) ) ;
918916
919917 let mut cmd = std:: process:: Command :: new ( "git" ) ;
920- cmd. env ( scope_env_key, SCOPE_ENV_VALUE ) ; // configure_command() should override it.
921- let args = [ "config" , "-l" , "--show-origin" , scope_option] . map ( String :: from) ;
922- configure_command ( & mut cmd, & args, dir) ;
918+ let args = [ "config" , "-l" , "--show-origin" ] . map ( String :: from) ;
919+ cmd. env ( "GIT_CONFIG_SYSTEM" , SCOPE_ENV_VALUE ) ;
920+ cmd. env ( "GIT_CONFIG_GLOBAL" , SCOPE_ENV_VALUE ) ;
921+ configure_command ( & mut cmd, & args, temp. path ( ) ) ;
923922
924923 let output = cmd. output ( ) . expect ( "can run git" ) ;
925- let stdout = output. stdout . to_str ( ) . expect ( "valid UTF-8" ) ;
924+ let lines: Vec < _ > = output
925+ . stdout
926+ . to_str ( )
927+ . expect ( "valid UTF-8" )
928+ . lines ( )
929+ . filter ( |line| !line. starts_with ( "command line:\t " ) )
930+ . collect ( ) ;
926931 let status = output. status . code ( ) . expect ( "terminated normally" ) ;
927- assert_eq ! ( stdout, "" , "should be no config variables to display" ) ;
928- assert_eq ! ( status, 0 , "reading the config should nonetheless succeed" ) ;
929- }
930-
931- #[ test]
932- fn configure_command_clears_system_scope ( ) {
933- check_configure_clears_scope ( "GIT_CONFIG_SYSTEM" , "--system" ) ;
934- }
935-
936- #[ test]
937- fn configure_command_clears_global_scope ( ) {
938- check_configure_clears_scope ( "GIT_CONFIG_GLOBAL" , "--global" ) ;
932+ assert_eq ! ( lines, Vec :: <& str >:: new( ) , "should be no config variables from files" ) ;
933+ assert_eq ! ( status, 0 , "reading the config should succeed" ) ;
939934 }
940935}
0 commit comments