@@ -20,7 +20,7 @@ use crate::core::build_steps::llvm;
2020use crate :: core:: config:: flags:: { Color , Flags , Warnings } ;
2121use crate :: utils:: cache:: { Interned , INTERNER } ;
2222use crate :: utils:: channel:: { self , GitInfo } ;
23- use crate :: utils:: helpers:: { exe, output, t} ;
23+ use crate :: utils:: helpers:: { self , exe, output, t} ;
2424use build_helper:: exit;
2525use serde:: { Deserialize , Deserializer } ;
2626use serde_derive:: Deserialize ;
@@ -1248,7 +1248,7 @@ impl Config {
12481248
12491249 // Infer the source directory. This is non-trivial because we want to support a downloaded bootstrap binary,
12501250 // 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 ) ;
12521252 // NOTE: we cannot support running from outside the repository because the only other path we have available
12531253 // is set at compile time, which can be wrong if bootstrap was downloaded rather than compiled locally.
12541254 // We still support running outside the repository if we find we aren't in a git directory.
@@ -2090,15 +2090,6 @@ impl Config {
20902090 build_helper:: util:: try_run ( cmd, self . is_verbose ( ) )
20912091 }
20922092
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-
21022093 pub ( crate ) fn test_args ( & self ) -> Vec < & str > {
21032094 let mut test_args = match self . cmd {
21042095 Subcommand :: Test { ref test_args, .. }
@@ -2130,7 +2121,7 @@ impl Config {
21302121 "`Config::read_file_by_commit` is not supported in non-git sources."
21312122 ) ;
21322123
2133- let mut git = self . git ( ) ;
2124+ let mut git = helpers :: git ( Some ( & self . src ) ) ;
21342125 git. arg ( "show" ) . arg ( format ! ( "{commit}:{}" , file. to_str( ) . unwrap( ) ) ) ;
21352126 output ( & mut git)
21362127 }
@@ -2436,15 +2427,16 @@ impl Config {
24362427 } ;
24372428
24382429 // 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" ] ) ) ;
24402432 let top_level = top_level. trim_end ( ) ;
24412433 let compiler = format ! ( "{top_level}/compiler/" ) ;
24422434 let library = format ! ( "{top_level}/library/" ) ;
24432435
24442436 // Look for a version to compare to based on the current commit.
24452437 // Only commits merged by bors will have CI artifacts.
24462438 let merge_base = output (
2447- self . git ( )
2439+ helpers :: git ( Some ( & self . src ) )
24482440 . arg ( "rev-list" )
24492441 . arg ( format ! ( "--author={}" , self . stage0_metadata. config. git_merge_commit_email) )
24502442 . args ( [ "-n1" , "--first-parent" , "HEAD" ] ) ,
@@ -2459,8 +2451,7 @@ impl Config {
24592451 }
24602452
24612453 // 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) )
24642455 . args( [ "diff-index" , "--quiet" , commit, "--" , & compiler, & library] )
24652456 . status( ) )
24662457 . success ( ) ;
@@ -2533,13 +2524,14 @@ impl Config {
25332524 if_unchanged : bool ,
25342525 ) -> Option < String > {
25352526 // 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" ] ) ) ;
25372529 let top_level = top_level. trim_end ( ) ;
25382530
25392531 // Look for a version to compare to based on the current commit.
25402532 // Only commits merged by bors will have CI artifacts.
25412533 let merge_base = output (
2542- self . git ( )
2534+ helpers :: git ( Some ( & self . src ) )
25432535 . arg ( "rev-list" )
25442536 . arg ( format ! ( "--author={}" , self . stage0_metadata. config. git_merge_commit_email) )
25452537 . args ( [ "-n1" , "--first-parent" , "HEAD" ] ) ,
@@ -2554,7 +2546,7 @@ impl Config {
25542546 }
25552547
25562548 // 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 ) ) ;
25582550 git. args ( [ "diff-index" , "--quiet" , commit, "--" ] ) ;
25592551
25602552 for path in modified_paths {
0 commit comments