Skip to content

Commit 8a4c985

Browse files
authored
Merge pull request #30 from Kobzol/allow-noop-change
Keep all intermediate state with `--allow-noop`
2 parents 0e5d6ce + e61a7b1 commit 8a4c985

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/sync.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ impl GitSync {
100100
}
101101
}
102102

103+
// Create a checkpoint to which we reset if something unusual happens
104+
let mut git_reset = GitResetOnDrop::new(orig_head, self.verbose);
105+
103106
// Update the last upstream SHA file. As a separate commit, since making it part of
104107
// the merge has confused the heck out of josh in the past.
105108
// We pass `--no-verify` to avoid running git hooks.
@@ -143,14 +146,6 @@ This updates the rust-version file to {upstream_sha}."#,
143146
)
144147
.context("cannot create preparation commit")?;
145148

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-
};
153-
154149
// Fetch given rustc commit.
155150
run_command(&["git", "fetch", &josh_url], self.verbose)
156151
.context("cannot fetch git state through Josh")?;
@@ -219,16 +214,16 @@ After you fix the conflicts, `git add` the changes and run `git merge --continue
219214
// Now detect if something has actually been pulled
220215
let current_sha = get_current_head_sha(self.verbose)?;
221216

222-
// This is the easy case, no merge was performed, so we bail
223-
if current_sha == sha_pre_merge {
217+
// This is the easy case, no merge was performed, so we bail, unless `allow_noop` is true
218+
if current_sha == sha_pre_merge && !allow_noop {
224219
eprintln!("No merge was performed, no changes to pull were found. Rolling back.");
225220
return Err(RustcPullError::NothingToPull);
226221
}
227222

228223
// But it can be more tricky - we can have only empty merge/rollup merge commits from
229224
// rustc, so a merge was created, but the in-tree diff can still be empty.
230-
// In that case we also bail.
231-
if self.has_empty_diff(&sha_pre_merge) {
225+
// In that case we also bail, unless `allow_noop` is true.
226+
if self.has_empty_diff(&sha_pre_merge) && !allow_noop {
232227
eprintln!("Only empty changes were pulled. Rolling back.");
233228
return Err(RustcPullError::NothingToPull);
234229
}

0 commit comments

Comments
 (0)