Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/git_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,13 @@ fn fast_forward_branch(
fetch_commit: &git2::AnnotatedCommit<'_>,
) -> Result<(), String> {
let refname = format!("refs/heads/{}", branch_name);

let target_obj = repo
.find_object(fetch_commit.id(), None)
.map_err(|e| format!("Pull fast-forward error: {}", e))?;
repo.checkout_tree(&target_obj, Some(git2::build::CheckoutBuilder::new().safe()))
.map_err(|e| format!("Pull checkout error: {}", e))?;

let mut branch_ref = repo
.find_reference(&refname)
.map_err(|e| format!("Pull fast-forward error: {}", e))?;
Expand All @@ -1451,8 +1458,6 @@ fn fast_forward_branch(
.map_err(|e| format!("Pull fast-forward error: {}", e))?;
repo.set_head(&refname)
.map_err(|e| format!("Pull head update error: {}", e))?;
repo.checkout_head(Some(git2::build::CheckoutBuilder::new().safe()))
.map_err(|e| format!("Pull checkout error: {}", e))?;
Ok(())
}

Expand Down