Skip to content

Commit 4393fa0

Browse files
Fetch origin master on checkout (#1684)
This ensures that git merge-base can find the right merge point; otherwise, our history looks to have diverged when the original checkout was made, which might be years ago.
1 parent 1744325 commit 4393fa0

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

collector/src/compile/execute/rustc.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,23 @@ fn checkout(artifact: &ArtifactId) -> anyhow::Result<()> {
165165
.status()
166166
.context("git fetch origin")?;
167167

168-
if !status.success() && matches!(artifact, ArtifactId::Tag(_)) {
168+
if !status.success() {
169169
log::warn!(
170-
"git fetch origin {} failed - trying default branch",
170+
"git fetch origin {} failed, this will likely break the build",
171171
artifact
172172
);
173-
status = Command::new("git")
174-
.current_dir("rust")
175-
.arg("fetch")
176-
.arg("origin")
177-
.arg("HEAD")
178-
.status()
179-
.context("git fetch origin HEAD")?;
180173
}
174+
175+
// Regardless, we fetch the default branch. Upstream Rust started using `git merge-base`
176+
// recently, which (reasonably) finds the wrong base if we think e.g. origin/master
177+
// diverged thousands of commits ago.
178+
status = Command::new("git")
179+
.current_dir("rust")
180+
.arg("fetch")
181+
.arg("origin")
182+
.arg("master")
183+
.status()
184+
.context("git fetch origin master")?;
181185
assert!(status.success(), "git fetch successful");
182186
} else {
183187
let status = Command::new("git")

0 commit comments

Comments
 (0)