@@ -20,7 +20,7 @@ use crate::core::build_steps::llvm;
20
20
use crate :: core:: config:: flags:: { Color , Flags , Warnings } ;
21
21
use crate :: utils:: cache:: { Interned , INTERNER } ;
22
22
use crate :: utils:: channel:: { self , GitInfo } ;
23
- use crate :: utils:: helpers:: { exe, output, t} ;
23
+ use crate :: utils:: helpers:: { self , exe, output, t} ;
24
24
use build_helper:: exit;
25
25
use serde:: { Deserialize , Deserializer } ;
26
26
use serde_derive:: Deserialize ;
@@ -1248,7 +1248,7 @@ impl Config {
1248
1248
1249
1249
// Infer the source directory. This is non-trivial because we want to support a downloaded bootstrap binary,
1250
1250
// running on a completely different machine from where it was compiled.
1251
- let mut cmd = Command :: new ( " git" ) ;
1251
+ let mut cmd = helpers :: git ( None ) ;
1252
1252
// NOTE: we cannot support running from outside the repository because the only other path we have available
1253
1253
// is set at compile time, which can be wrong if bootstrap was downloaded rather than compiled locally.
1254
1254
// We still support running outside the repository if we find we aren't in a git directory.
@@ -2090,15 +2090,6 @@ impl Config {
2090
2090
build_helper:: util:: try_run ( cmd, self . is_verbose ( ) )
2091
2091
}
2092
2092
2093
- /// A git invocation which runs inside the source directory.
2094
- ///
2095
- /// Use this rather than `Command::new("git")` in order to support out-of-tree builds.
2096
- pub ( crate ) fn git ( & self ) -> Command {
2097
- let mut git = Command :: new ( "git" ) ;
2098
- git. current_dir ( & self . src ) ;
2099
- git
2100
- }
2101
-
2102
2093
pub ( crate ) fn test_args ( & self ) -> Vec < & str > {
2103
2094
let mut test_args = match self . cmd {
2104
2095
Subcommand :: Test { ref test_args, .. }
@@ -2130,7 +2121,7 @@ impl Config {
2130
2121
"`Config::read_file_by_commit` is not supported in non-git sources."
2131
2122
) ;
2132
2123
2133
- let mut git = self . git ( ) ;
2124
+ let mut git = helpers :: git ( Some ( & self . src ) ) ;
2134
2125
git. arg ( "show" ) . arg ( format ! ( "{commit}:{}" , file. to_str( ) . unwrap( ) ) ) ;
2135
2126
output ( & mut git)
2136
2127
}
@@ -2436,15 +2427,16 @@ impl Config {
2436
2427
} ;
2437
2428
2438
2429
// Handle running from a directory other than the top level
2439
- let top_level = output ( self . git ( ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) ;
2430
+ let top_level =
2431
+ output ( helpers:: git ( Some ( & self . src ) ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) ;
2440
2432
let top_level = top_level. trim_end ( ) ;
2441
2433
let compiler = format ! ( "{top_level}/compiler/" ) ;
2442
2434
let library = format ! ( "{top_level}/library/" ) ;
2443
2435
2444
2436
// Look for a version to compare to based on the current commit.
2445
2437
// Only commits merged by bors will have CI artifacts.
2446
2438
let merge_base = output (
2447
- self . git ( )
2439
+ helpers :: git ( Some ( & self . src ) )
2448
2440
. arg ( "rev-list" )
2449
2441
. arg ( format ! ( "--author={}" , self . stage0_metadata. config. git_merge_commit_email) )
2450
2442
. args ( [ "-n1" , "--first-parent" , "HEAD" ] ) ,
@@ -2459,8 +2451,7 @@ impl Config {
2459
2451
}
2460
2452
2461
2453
// Warn if there were changes to the compiler or standard library since the ancestor commit.
2462
- let has_changes = !t ! ( self
2463
- . git( )
2454
+ let has_changes = !t ! ( helpers:: git( Some ( & self . src) )
2464
2455
. args( [ "diff-index" , "--quiet" , commit, "--" , & compiler, & library] )
2465
2456
. status( ) )
2466
2457
. success ( ) ;
@@ -2533,13 +2524,14 @@ impl Config {
2533
2524
if_unchanged : bool ,
2534
2525
) -> Option < String > {
2535
2526
// Handle running from a directory other than the top level
2536
- let top_level = output ( self . git ( ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) ;
2527
+ let top_level =
2528
+ output ( helpers:: git ( Some ( & self . src ) ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) ;
2537
2529
let top_level = top_level. trim_end ( ) ;
2538
2530
2539
2531
// Look for a version to compare to based on the current commit.
2540
2532
// Only commits merged by bors will have CI artifacts.
2541
2533
let merge_base = output (
2542
- self . git ( )
2534
+ helpers :: git ( Some ( & self . src ) )
2543
2535
. arg ( "rev-list" )
2544
2536
. arg ( format ! ( "--author={}" , self . stage0_metadata. config. git_merge_commit_email) )
2545
2537
. args ( [ "-n1" , "--first-parent" , "HEAD" ] ) ,
@@ -2554,7 +2546,7 @@ impl Config {
2554
2546
}
2555
2547
2556
2548
// Warn if there were changes to the compiler or standard library since the ancestor commit.
2557
- let mut git = self . git ( ) ;
2549
+ let mut git = helpers :: git ( Some ( & self . src ) ) ;
2558
2550
git. args ( [ "diff-index" , "--quiet" , commit, "--" ] ) ;
2559
2551
2560
2552
for path in modified_paths {
0 commit comments