@@ -603,7 +603,7 @@ fn configure_command<'a>(
603
603
. env_remove ( "GIT_ASKPASS" )
604
604
. env_remove ( "SSH_ASKPASS" )
605
605
. env ( "MSYS" , msys_for_git_bash_on_windows)
606
- . env ( "GIT_CONFIG_SYSTEM " , NULL_DEVICE )
606
+ . env ( "GIT_CONFIG_NOSYSTEM " , "1" )
607
607
. env ( "GIT_CONFIG_GLOBAL" , NULL_DEVICE )
608
608
. env ( "GIT_TERMINAL_PROMPT" , "false" )
609
609
. env ( "GIT_AUTHOR_DATE" , "2000-01-01 00:00:00 +0000" )
@@ -898,43 +898,38 @@ mod tests {
898
898
} else {
899
899
& [ dir. join ( SCOPE_ENV_VALUE ) , dir. join ( "-" ) , dir. join ( ":" ) ]
900
900
} ;
901
-
902
901
// Create the files.
903
902
for path in paths {
904
903
std:: fs:: write ( path, CONFIG_DATA ) . expect ( "can write contents" ) ;
905
904
}
906
-
907
905
// Verify the files. This is mostly to show we really made a `\\?\...\NUL` on Windows.
908
906
for path in paths {
909
907
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 " ) ;
911
909
}
912
910
}
913
911
914
- fn check_configure_clears_scope ( scope_env_key : & str , scope_option : & str ) {
912
+ #[ test]
913
+ fn configure_command_clears_external_config ( ) {
915
914
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 ( ) ) ;
918
916
919
917
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 ( ) ) ;
923
922
924
923
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 ( ) ;
926
931
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" ) ;
939
934
}
940
935
}
0 commit comments