@@ -868,6 +868,8 @@ impl<'a> Drop for Env<'a> {
868868#[ cfg( test) ]  
869869mod  tests { 
870870    use  super :: * ; 
871+     use  std:: fs:: File ; 
872+     use  std:: io:: Write ; 
871873
872874    #[ test]  
873875    fn  parse_version ( )  { 
@@ -882,4 +884,38 @@ mod tests {
882884    fn  parse_version_with_trailing_newline ( )  { 
883885        assert_eq ! ( git_version_from_bytes( b"git version 2.37.2\n " ) . unwrap( ) ,  ( 2 ,  37 ,  2 ) ) ; 
884886    } 
887+ 
888+     fn  check_configure_clears_scope ( scope_option :  & str )  { 
889+         let  temp = tempfile:: TempDir :: new ( ) . expect ( "can create temp dir" ) ; 
890+         #[ cfg( windows) ]  
891+         let  names = [ "-" ] ; 
892+         #[ cfg( not( windows) ) ]  
893+         let  names = [ "-" ,  ":" ] ; 
894+         for  name in  names { 
895+             File :: create ( temp. path ( ) . join ( name) ) 
896+                 . expect ( "can create file" ) 
897+                 . write_all ( b"[foo]\n \t bar = baz\n " ) 
898+                 . expect ( "can write contents" ) ; 
899+         } 
900+         let  mut  cmd = std:: process:: Command :: new ( "git" ) ; 
901+         let  args = [ "config" ,  scope_option,  "foo.bar" ] . map ( String :: from) ; 
902+         configure_command ( & mut  cmd,  & args,  temp. path ( ) ) ; 
903+         let  output = cmd. output ( ) . expect ( "can run git" ) ; 
904+         let  stdout = output. stdout . to_str ( ) . expect ( "valid UTF-8" ) ; 
905+         let  status = output. status . code ( ) . expect ( "terminated normally" ) ; 
906+         assert_eq ! ( stdout,  "" ,  "should be no config variable to display" ) ; 
907+         assert_eq ! ( status,  1 ,  "exit status should indicate config variable is absent" ) ; 
908+ 
909+         temp. close ( ) . expect ( "Test bug: Should be able to delete everything" ) ; 
910+     } 
911+ 
912+     #[ test]  
913+     fn  configure_command_clears_system_scope ( )  { 
914+         check_configure_clears_scope ( "--system" ) ; 
915+     } 
916+ 
917+     #[ test]  
918+     fn  configure_command_clears_global_scope ( )  { 
919+         check_configure_clears_scope ( "--global" ) ; 
920+     } 
885921} 
0 commit comments