File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -257,12 +257,26 @@ impl Command {
257
257
} )
258
258
. context ( "FAILED to fetch new commits, something went wrong (committing the rust-version file has been undone)" ) ?;
259
259
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
+
260
269
// Merge the fetched commit.
261
270
const MERGE_COMMIT_MESSAGE : & str = "Merge from rustc" ;
262
271
cmd ! ( sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}" )
263
272
. run ( )
264
273
. context ( "FAILED to merge new commits, something went wrong" ) ?;
265
274
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
+
266
280
drop ( josh) ;
267
281
Ok ( ( ) )
268
282
}
You can’t perform that action at this time.
0 commit comments