@@ -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.
@@ -2101,15 +2101,6 @@ impl Config {
2101
2101
build_helper:: util:: try_run ( cmd, self . is_verbose ( ) )
2102
2102
}
2103
2103
2104
- /// A git invocation which runs inside the source directory.
2105
- ///
2106
- /// Use this rather than `Command::new("git")` in order to support out-of-tree builds.
2107
- pub ( crate ) fn git ( & self ) -> Command {
2108
- let mut git = Command :: new ( "git" ) ;
2109
- git. current_dir ( & self . src ) ;
2110
- git
2111
- }
2112
-
2113
2104
pub ( crate ) fn test_args ( & self ) -> Vec < & str > {
2114
2105
let mut test_args = match self . cmd {
2115
2106
Subcommand :: Test { ref test_args, .. }
@@ -2138,10 +2129,10 @@ impl Config {
2138
2129
/// Return the version it would have used for the given commit.
2139
2130
pub ( crate ) fn artifact_version_part ( & self , commit : & str ) -> String {
2140
2131
let ( channel, version) = if self . rust_info . is_managed_git_subrepository ( ) {
2141
- let mut channel = self . git ( ) ;
2132
+ let mut channel = helpers :: git ( Some ( & self . src ) ) ;
2142
2133
channel. arg ( "show" ) . arg ( format ! ( "{commit}:src/ci/channel" ) ) ;
2143
2134
let channel = output ( & mut channel) ;
2144
- let mut version = self . git ( ) ;
2135
+ let mut version = helpers :: git ( Some ( & self . src ) ) ;
2145
2136
version. arg ( "show" ) . arg ( format ! ( "{commit}:src/version" ) ) ;
2146
2137
let version = output ( & mut version) ;
2147
2138
( channel. trim ( ) . to_owned ( ) , version. trim ( ) . to_owned ( ) )
@@ -2435,15 +2426,16 @@ impl Config {
2435
2426
} ;
2436
2427
2437
2428
// Handle running from a directory other than the top level
2438
- let top_level = output ( self . git ( ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) ;
2429
+ let top_level =
2430
+ output ( helpers:: git ( Some ( & self . src ) ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) ;
2439
2431
let top_level = top_level. trim_end ( ) ;
2440
2432
let compiler = format ! ( "{top_level}/compiler/" ) ;
2441
2433
let library = format ! ( "{top_level}/library/" ) ;
2442
2434
2443
2435
// Look for a version to compare to based on the current commit.
2444
2436
// Only commits merged by bors will have CI artifacts.
2445
2437
let merge_base = output (
2446
- self . git ( )
2438
+ helpers :: git ( Some ( & self . src ) )
2447
2439
. arg ( "rev-list" )
2448
2440
. arg ( format ! ( "--author={}" , self . stage0_metadata. config. git_merge_commit_email) )
2449
2441
. args ( [ "-n1" , "--first-parent" , "HEAD" ] ) ,
@@ -2458,8 +2450,7 @@ impl Config {
2458
2450
}
2459
2451
2460
2452
// Warn if there were changes to the compiler or standard library since the ancestor commit.
2461
- let has_changes = !t ! ( self
2462
- . git( )
2453
+ let has_changes = !t ! ( helpers:: git( Some ( & self . src) )
2463
2454
. args( [ "diff-index" , "--quiet" , commit, "--" , & compiler, & library] )
2464
2455
. status( ) )
2465
2456
. success ( ) ;
@@ -2532,13 +2523,14 @@ impl Config {
2532
2523
if_unchanged : bool ,
2533
2524
) -> Option < String > {
2534
2525
// Handle running from a directory other than the top level
2535
- let top_level = output ( self . git ( ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) ;
2526
+ let top_level =
2527
+ output ( helpers:: git ( Some ( & self . src ) ) . args ( [ "rev-parse" , "--show-toplevel" ] ) ) ;
2536
2528
let top_level = top_level. trim_end ( ) ;
2537
2529
2538
2530
// Look for a version to compare to based on the current commit.
2539
2531
// Only commits merged by bors will have CI artifacts.
2540
2532
let merge_base = output (
2541
- self . git ( )
2533
+ helpers :: git ( Some ( & self . src ) )
2542
2534
. arg ( "rev-list" )
2543
2535
. arg ( format ! ( "--author={}" , self . stage0_metadata. config. git_merge_commit_email) )
2544
2536
. args ( [ "-n1" , "--first-parent" , "HEAD" ] ) ,
@@ -2553,7 +2545,7 @@ impl Config {
2553
2545
}
2554
2546
2555
2547
// Warn if there were changes to the compiler or standard library since the ancestor commit.
2556
- let mut git = self . git ( ) ;
2548
+ let mut git = helpers :: git ( Some ( & self . src ) ) ;
2557
2549
git. args ( [ "diff-index" , "--quiet" , commit, "--" ] ) ;
2558
2550
2559
2551
for path in modified_paths {
0 commit comments