mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-28 04:47:42 +03:00
Fix for branches incorrectly deleted
If a branch is being "unapplied' due to conflicts - dont delete the state
This commit is contained in:
parent
dfec47a962
commit
6ed54349d0
@ -252,7 +252,7 @@ pub fn unapply_without_saving_virtual_branch(project: &Project, branch_id: Stack
|
||||
let default_target = state.get_default_target()?;
|
||||
let target_commit = ctx.repository().find_commit(default_target.sha)?;
|
||||
// NB: unapply_without_saving is also called from save_and_unapply
|
||||
branch_manager.unapply_without_saving(branch_id, guard.write_permission(), &target_commit)?;
|
||||
branch_manager.unapply(branch_id, guard.write_permission(), &target_commit, true)?;
|
||||
state.delete_branch_entry(&branch_id)
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ impl BranchManager<'_> {
|
||||
// Convert the vbranch to a real branch
|
||||
let real_branch = self.build_real_branch(&mut target_branch)?;
|
||||
|
||||
self.unapply_without_saving(branch_id, perm, &target_commit)?;
|
||||
self.unapply(branch_id, perm, &target_commit, false)?;
|
||||
|
||||
vb_state.update_ordering()?;
|
||||
|
||||
@ -53,11 +53,12 @@ impl BranchManager<'_> {
|
||||
}
|
||||
|
||||
#[instrument(level = tracing::Level::DEBUG, skip(self, perm), err(Debug))]
|
||||
pub(crate) fn unapply_without_saving(
|
||||
pub(crate) fn unapply(
|
||||
&self,
|
||||
branch_id: StackId,
|
||||
perm: &mut WorktreeWritePermission,
|
||||
target_commit: &Commit,
|
||||
delete_vb_state: bool,
|
||||
) -> Result<()> {
|
||||
let vb_state = self.ctx.project().virtual_branches();
|
||||
let Some(branch) = vb_state.try_branch(branch_id)? else {
|
||||
@ -128,7 +129,9 @@ impl BranchManager<'_> {
|
||||
.checkout()
|
||||
.context("failed to checkout tree")?;
|
||||
|
||||
if delete_vb_state {
|
||||
self.ctx.delete_branch_reference(&branch)?;
|
||||
}
|
||||
|
||||
vbranch::ensure_selected_for_changes(&vb_state)
|
||||
.context("failed to ensure selected for changes")?;
|
||||
|
Loading…
Reference in New Issue
Block a user