Skip to content

Commit

Permalink
Rollup merge of rust-lang#106310 - compiler-errors:old-git, r=jyn514
Browse files Browse the repository at this point in the history
Dont use `--merge-base` during bootstrap formatting subcommand

I use a development image with Ubuntu 20.04 LTS, which has git 2.25.

Recently, `./x.py test tidy --bless` regressed in rust-lang#105702 because it uses the `--merge-base` option on `diff-index`, which was only introduced in git 2.30 (git/git@0f5a1d4). Luckily, it can be replicated via two calls to `git merge-base` + `git diff-index`, so let's just use that.
  • Loading branch information
jyn514 committed Dec 31, 2022
2 parents 5c72535 + e2c5999 commit 88470f3
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/bootstrap/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,19 @@ fn update_rustfmt_version(build: &Builder<'_>) {
///
/// Returns `None` if all files should be formatted.
fn get_modified_rs_files(build: &Builder<'_>) -> Option<Vec<String>> {
let Ok(remote) = get_rust_lang_rust_remote() else {return None;};
let Ok(remote) = get_rust_lang_rust_remote() else { return None; };
if !verify_rustfmt_version(build) {
return None;
}

let merge_base =
output(build.config.git().arg("merge-base").arg(&format!("{remote}/master")).arg("HEAD"));
Some(
output(
build
.config
.git()
.arg("diff-index")
.arg("--name-only")
.arg("--merge-base")
.arg(&format!("{remote}/master")),
)
.lines()
.map(|s| s.trim().to_owned())
.filter(|f| Path::new(f).extension().map_or(false, |ext| ext == "rs"))
.collect(),
output(build.config.git().arg("diff-index").arg("--name-only").arg(merge_base.trim()))
.lines()
.map(|s| s.trim().to_owned())
.filter(|f| Path::new(f).extension().map_or(false, |ext| ext == "rs"))
.collect(),
)
}

Expand Down

0 comments on commit 88470f3

Please sign in to comment.