Skip to content

Commit

Permalink
rewrite: inline and rewrite ref_target_update()
Browse files Browse the repository at this point in the history
I rewrote `old_target` and `new_target` to more accurately represent
the change; the old target should be a normal (singleton) ref.
  • Loading branch information
martinvonz committed Apr 15, 2024
1 parent 116761d commit 9c55fcc
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,6 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> {
self.rebased
}

fn ref_target_update(old_id: CommitId, new_ids: Vec<CommitId>) -> (RefTarget, RefTarget) {
let old_ids = std::iter::repeat(old_id).take(new_ids.len());
(
RefTarget::from_legacy_form([], old_ids),
RefTarget::from_legacy_form([], new_ids),
)
}

fn update_references(
&mut self,
old_commit_id: CommitId,
Expand Down Expand Up @@ -393,8 +385,13 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> {
}
}
}
let (old_target, new_target) =
DescendantRebaser::ref_target_update(old_commit_id, new_commit_ids);

let old_target = RefTarget::normal(old_commit_id.clone());
assert!(!new_commit_ids.is_empty());
let new_target = RefTarget::from_legacy_form(
std::iter::repeat(old_commit_id).take(new_commit_ids.len() - 1),
new_commit_ids,
);
for branch_name in &branch_updates {
self.mut_repo
.merge_local_branch(branch_name, &old_target, &new_target);
Expand Down

0 comments on commit 9c55fcc

Please sign in to comment.