File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -81,12 +81,22 @@ impl GitSync {
8181 } ;
8282 let num_roots_before = num_roots ( ) ?;
8383
84+ let sha = cmd ! ( sh, "git rev-parse HEAD" ) . output ( ) . context ( "FAILED to get current commit" ) ?. stdout ;
85+
8486 // Merge the fetched commit.
8587 const MERGE_COMMIT_MESSAGE : & str = "Merge from rustc" ;
8688 cmd ! ( sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}" )
8789 . run ( )
8890 . context ( "FAILED to merge new commits, something went wrong" ) ?;
8991
92+ let current_sha = cmd ! ( sh, "git rev-parse HEAD" ) . output ( ) . context ( "FAILED to get current commit" ) ?. stdout ;
93+ if current_sha == sha {
94+ cmd ! ( sh, "git reset --hard HEAD^" )
95+ . run ( )
96+ . expect ( "FAILED to clean up after creating the preparation commit" ) ;
97+ return Err ( anyhow:: anyhow!( "No merge was performed, nothing to pull. Rolled back the preparation commit." ) ) ;
98+ }
99+
90100 // Check that the number of roots did not increase.
91101 if num_roots ( ) ? != num_roots_before {
92102 bail ! ( "Josh created a new root commit. This is probably not the history you want." ) ;
You can’t perform that action at this time.
0 commit comments