@@ -45,6 +45,7 @@ impl GitSync {
45
45
& self ,
46
46
upstream_repo : String ,
47
47
upstream_commit : Option < String > ,
48
+ allow_noop : bool ,
48
49
) -> Result < PullResult , RustcPullError > {
49
50
// The upstream commit that we want to pull
50
51
let upstream_sha = if let Some ( sha) = upstream_commit {
@@ -142,8 +143,13 @@ This updates the rust-version file to {upstream_sha}."#,
142
143
)
143
144
. context ( "cannot create preparation commit" ) ?;
144
145
145
- // Make sure that we reset the above commit if something fails
146
- let mut git_reset = GitResetOnDrop :: new ( orig_head, self . verbose ) ;
146
+ // Make sure that we reset either to the default HEAD, or the preparation commit, if
147
+ // something bad happens
148
+ let mut git_reset = if allow_noop {
149
+ GitResetOnDrop :: new ( get_current_head_sha ( self . verbose ) ?, self . verbose )
150
+ } else {
151
+ GitResetOnDrop :: new ( orig_head, self . verbose )
152
+ } ;
147
153
148
154
// Fetch given rustc commit.
149
155
run_command ( & [ "git" , "fetch" , & josh_url] , self . verbose )
@@ -215,17 +221,15 @@ After you fix the conflicts, `git add` the changes and run `git merge --continue
215
221
216
222
// This is the easy case, no merge was performed, so we bail
217
223
if current_sha == sha_pre_merge {
218
- eprintln ! (
219
- "No merge was performed, no changes to pull were found. Rolling back the preparation commit."
220
- ) ;
224
+ eprintln ! ( "No merge was performed, no changes to pull were found. Rolling back." ) ;
221
225
return Err ( RustcPullError :: NothingToPull ) ;
222
226
}
223
227
224
228
// But it can be more tricky - we can have only empty merge/rollup merge commits from
225
229
// rustc, so a merge was created, but the in-tree diff can still be empty.
226
230
// In that case we also bail.
227
231
if self . has_empty_diff ( & sha_pre_merge) {
228
- eprintln ! ( "Only empty changes were pulled. Rolling back the preparation commit ." ) ;
232
+ eprintln ! ( "Only empty changes were pulled. Rolling back." ) ;
229
233
return Err ( RustcPullError :: NothingToPull ) ;
230
234
}
231
235
0 commit comments