@@ -453,6 +453,13 @@ mod exe_info {
453
453
check_exe_info ( ) ;
454
454
}
455
455
456
+ #[ test]
457
+ #[ serial]
458
+ fn tolerates_git_config_env_var ( ) {
459
+ let _env = gix_testtools:: Env :: new ( ) . set ( "GIT_CONFIG" , NULL_DEVICE ) ;
460
+ check_exe_info ( ) ;
461
+ }
462
+
456
463
#[ test]
457
464
#[ serial]
458
465
fn same_result_with_broken_temp ( ) {
@@ -480,6 +487,19 @@ mod exe_info {
480
487
assert_eq ! ( with_unmodified_env, with_oversanitized_env) ;
481
488
}
482
489
490
+ #[ test]
491
+ #[ serial]
492
+ fn same_result_with_git_config_env_var ( ) {
493
+ let with_unmodified_env = exe_info ( ) ;
494
+
495
+ let with_git_config_env_var = {
496
+ let _env = gix_testtools:: Env :: new ( ) . set ( "GIT_CONFIG" , NULL_DEVICE ) ;
497
+ exe_info ( )
498
+ } ;
499
+
500
+ assert_eq ! ( with_unmodified_env, with_git_config_env_var) ;
501
+ }
502
+
483
503
#[ test]
484
504
#[ serial]
485
505
#[ cfg( not( target_os = "macos" ) ) ] // Assumes no higher "unknown" scope. The `nosystem` case works.
@@ -556,6 +576,33 @@ mod exe_info {
556
576
) ;
557
577
}
558
578
579
+ #[ test]
580
+ #[ serial]
581
+ fn never_from_git_config_env_var ( ) {
582
+ let repo = gix_testtools:: scripted_fixture_read_only ( "local_config.sh" ) . expect ( "script succeeds" ) ;
583
+
584
+ // Get an absolute path to a config file that is non-UNC if possible so any Git accepts it.
585
+ let config_path = std:: env:: current_dir ( )
586
+ . expect ( "got CWD" )
587
+ . join ( repo)
588
+ . join ( ".git" )
589
+ . join ( "config" )
590
+ . to_str ( )
591
+ . expect ( "valid UTF-8" )
592
+ . to_owned ( ) ;
593
+
594
+ let _env = gix_testtools:: Env :: new ( )
595
+ . set ( "GIT_CONFIG_NOSYSTEM" , "1" )
596
+ . set ( "GIT_CONFIG_GLOBAL" , NULL_DEVICE )
597
+ . set ( "GIT_CONFIG" , config_path) ;
598
+
599
+ let maybe_path = exe_info ( ) ;
600
+ assert_eq ! (
601
+ maybe_path, None ,
602
+ "Should find no config path from GIT_CONFIG (even if nonempty)"
603
+ ) ;
604
+ }
605
+
559
606
#[ test]
560
607
fn first_file_from_config_with_origin ( ) {
561
608
let macos =
0 commit comments