Skip to content

Commit b4f002d

Browse files
authored
Rollup merge of #127552 - onur-ozkan:unnecessary-git-usage, r=Kobzol
remove unnecessary `git` usages `Config::src` already contains the top-level path, so we don't need to add git overhead just to reach this path.
2 parents 8ceb4e4 + 0134bd2 commit b4f002d

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

src/bootstrap/src/core/config/config.rs

+7-16
Original file line numberDiff line numberDiff line change
@@ -2466,14 +2466,6 @@ impl Config {
24662466
}
24672467
};
24682468

2469-
// Handle running from a directory other than the top level
2470-
let top_level = output(
2471-
&mut helpers::git(Some(&self.src)).args(["rev-parse", "--show-toplevel"]).command,
2472-
);
2473-
let top_level = top_level.trim_end();
2474-
let compiler = format!("{top_level}/compiler/");
2475-
let library = format!("{top_level}/library/");
2476-
24772469
// Look for a version to compare to based on the current commit.
24782470
// Only commits merged by bors will have CI artifacts.
24792471
let merge_base = output(
@@ -2494,7 +2486,9 @@ impl Config {
24942486

24952487
// Warn if there were changes to the compiler or standard library since the ancestor commit.
24962488
let has_changes = !t!(helpers::git(Some(&self.src))
2497-
.args(["diff-index", "--quiet", commit, "--", &compiler, &library])
2489+
.args(["diff-index", "--quiet", commit])
2490+
.arg("--")
2491+
.args([self.src.join("compiler"), self.src.join("library")])
24982492
.command
24992493
.status())
25002494
.success();
@@ -2566,12 +2560,6 @@ impl Config {
25662560
option_name: &str,
25672561
if_unchanged: bool,
25682562
) -> Option<String> {
2569-
// Handle running from a directory other than the top level
2570-
let top_level = output(
2571-
&mut helpers::git(Some(&self.src)).args(["rev-parse", "--show-toplevel"]).command,
2572-
);
2573-
let top_level = top_level.trim_end();
2574-
25752563
// Look for a version to compare to based on the current commit.
25762564
// Only commits merged by bors will have CI artifacts.
25772565
let merge_base = output(
@@ -2594,8 +2582,11 @@ impl Config {
25942582
let mut git = helpers::git(Some(&self.src));
25952583
git.args(["diff-index", "--quiet", commit, "--"]);
25962584

2585+
// Handle running from a directory other than the top level
2586+
let top_level = &self.src;
2587+
25972588
for path in modified_paths {
2598-
git.arg(format!("{top_level}/{path}"));
2589+
git.arg(top_level.join(path));
25992590
}
26002591

26012592
let has_changes = !t!(git.command.status()).success();

0 commit comments

Comments
 (0)