File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments