rewrite: remove unneeded Result from CommitRewriter::reparent()

reparent() just configures new CommitBuilder instance, which should never fail.
This commit is contained in:
Yuya Nishihara 2024-12-20 18:09:57 +09:00
parent d0f0e8dcff
commit f7fd523dd8
5 changed files with 7 additions and 8 deletions

View file

@ -287,7 +287,7 @@ pub(crate) fn cmd_fix(
if changes > 0 {
num_fixed_commits += 1;
let new_tree = tree_builder.write_tree(rewriter.mut_repo().store())?;
let builder = rewriter.reparent(command.settings())?;
let builder = rewriter.reparent(command.settings());
builder.set_tree_id(new_tree).write()?;
}
Ok(())

View file

@ -90,7 +90,7 @@ pub(crate) fn cmd_simplify_parents(
let num_new_heads = rewriter.new_parents().len();
if rewriter.parents_changed() {
rewriter.reparent(command.settings())?.write()?;
rewriter.reparent(command.settings()).write()?;
if num_new_heads < num_old_heads {
simplified_commits += 1;

View file

@ -279,7 +279,7 @@ pub fn absorb_hunks(
// Remove selected hunks from the source commit by reparent()
if rewriter.old_commit().id() == source.commit.id() {
// TODO: should we abandon the source if it's discardable?
rewriter.reparent(settings)?.write()?;
rewriter.reparent(settings).write()?;
num_rebased += 1;
return Ok(());
}

View file

@ -1354,7 +1354,7 @@ impl MutableRepo {
let mut num_reparented = 0;
self.transform_descendants(settings, roots, |rewriter| {
if rewriter.parents_changed() {
let builder = rewriter.reparent(settings)?;
let builder = rewriter.reparent(settings);
builder.write()?;
num_reparented += 1;
}

View file

@ -295,11 +295,10 @@ impl<'repo> CommitRewriter<'repo> {
/// Rewrite the old commit onto the new parents without changing its
/// contents. Returns a `CommitBuilder` for the new commit.
pub fn reparent(self, settings: &UserSettings) -> BackendResult<CommitBuilder<'repo>> {
Ok(self
.mut_repo
pub fn reparent(self, settings: &UserSettings) -> CommitBuilder<'repo> {
self.mut_repo
.rewrite_commit(settings, &self.old_commit)
.set_parents(self.new_parents))
.set_parents(self.new_parents)
}
}