Skip to content

Commit 0132d4c

Browse files
committed
josh rustc-pull: check that no new root commits get created
1 parent 6b787f9 commit 0132d4c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

miri-script/src/commands.rs

+14
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,26 @@ impl Command {
257257
})
258258
.context("FAILED to fetch new commits, something went wrong (committing the rust-version file has been undone)")?;
259259

260+
// This should not add any new root commits. So count those before and after merging.
261+
let num_roots = || -> Result<u32> {
262+
Ok(cmd!(sh, "git rev-list HEAD --max-parents=0 --count")
263+
.read()
264+
.context("failed to determine the number of root commits")?
265+
.parse::<u32>()?)
266+
};
267+
let num_roots_before = num_roots()?;
268+
260269
// Merge the fetched commit.
261270
const MERGE_COMMIT_MESSAGE: &str = "Merge from rustc";
262271
cmd!(sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}")
263272
.run()
264273
.context("FAILED to merge new commits, something went wrong")?;
265274

275+
// Check that the number of roots did not increase.
276+
if num_roots()? != num_roots_before {
277+
bail!("Josh created a new root commit. This is probably not the history you want.");
278+
}
279+
266280
drop(josh);
267281
Ok(())
268282
}

0 commit comments

Comments
 (0)