Merge pull request #5050 from gitbutlerapp/fix-upstream-integration-when-no-branches

Fix upstream integration when there are no new branches
This commit is contained in:
Caleb Owens 2024-10-07 11:07:27 +02:00 committed by GitHub
commit 359ef1e216
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -326,9 +326,22 @@ pub(crate) fn integrate_upstream(
virtual_branches_state.set_branch(branch.clone())?;
}
// Now that we've potentially updated the branch trees, lets checkout
// the result of merging them all together.
checkout_branch_trees(command_context, permission)?;
// checkout_branch_trees won't checkout anything if there are no
// applied branches, and returns the current_wd_tree as its result.
// This is very sensible, but in this case, we want to checkout the
// new target sha.
if branches.is_empty() {
context
.repository
.checkout_tree_builder(&context.new_target.tree()?)
.force()
.remove_untracked()
.checkout()?;
} else {
// Now that we've potentially updated the branch trees, lets checkout
// the result of merging them all together.
checkout_branch_trees(command_context, permission)?;
}
virtual_branches_state.set_default_target(Target {
sha: context.new_target.id(),