This commit is contained in:
Stephan Dilly 2021-09-29 17:38:26 +02:00
parent 23516f1a41
commit 9f8fc6b907

View file

@ -8,18 +8,6 @@ use crate::{
use super::CommitId;
fn rebase_branch_repo(
repo: &Repository,
branch_name: &str,
) -> Result<CommitId> {
let branch = repo.find_branch(branch_name, BranchType::Local)?;
let annotated =
repo.reference_to_annotated_commit(&branch.into_reference())?;
conflict_free_rebase(repo, &annotated)
}
/// rebase current HEAD on `branch`
pub fn rebase_branch(
repo_path: &str,
@ -32,6 +20,18 @@ pub fn rebase_branch(
rebase_branch_repo(&repo, branch)
}
fn rebase_branch_repo(
repo: &Repository,
branch_name: &str,
) -> Result<CommitId> {
let branch = repo.find_branch(branch_name, BranchType::Local)?;
let annotated =
repo.reference_to_annotated_commit(&branch.into_reference())?;
conflict_free_rebase(repo, &annotated)
}
/// rebase attempt which aborts and undo's rebase if any conflict appears
pub fn conflict_free_rebase(
repo: &git2::Repository,
@ -43,7 +43,6 @@ pub fn conflict_free_rebase(
let mut last_commit = None;
while let Some(op) = rebase.next() {
let _op = op?;
// dbg!(op.id());
if repo.index()?.has_conflicts() {
rebase.abort()?;