Skip to content

Commit 38f675f

Browse files
Merge pull request #9496 from gitbutlerapp/fix-branch-creation
Fix branch creation
2 parents 4f6daf0 + edb860a commit 38f675f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

crates/gitbutler-branch-actions/src/branch_manager/branch_creation.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use gitbutler_repo::RepositoryExt as _;
1818
use gitbutler_repo_actions::RepoActionsExt;
1919
use gitbutler_stack::{BranchOwnershipClaims, Stack, StackId};
2020
use gitbutler_time::time::now_since_unix_epoch_ms;
21-
use gitbutler_workspace::branch_trees::{update_uncommited_changes, WorkspaceState};
21+
use gitbutler_workspace::branch_trees::{update_uncommited_changes_with_tree, WorkspaceState};
2222
#[allow(deprecated)]
2323
use tracing::instrument;
2424

@@ -122,6 +122,7 @@ impl BranchManager<'_> {
122122
pr_number: Option<usize>,
123123
perm: &mut WorktreeWritePermission,
124124
) -> Result<StackId> {
125+
let old_cwd = self.ctx.repo().create_wd_tree(0)?.id();
125126
let old_workspace = WorkspaceState::create(self.ctx, perm.read_permission())?;
126127
// only set upstream if it's not the default target
127128
let upstream_branch = match upstream_branch {
@@ -252,7 +253,7 @@ impl BranchManager<'_> {
252253
)?;
253254
self.ctx.add_branch_reference(&branch)?;
254255

255-
match self.apply_branch(branch.id, perm, old_workspace) {
256+
match self.apply_branch(branch.id, perm, old_workspace, old_cwd) {
256257
Ok(_) => Ok(branch.id),
257258
Err(err)
258259
if err
@@ -275,6 +276,7 @@ impl BranchManager<'_> {
275276
stack_id: StackId,
276277
perm: &mut WorktreeWritePermission,
277278
workspace_state: WorkspaceState,
279+
old_cwd: git2::Oid,
278280
) -> Result<String> {
279281
let repo = self.ctx.repo();
280282

@@ -402,7 +404,14 @@ impl BranchManager<'_> {
402404

403405
let new_workspace = WorkspaceState::create(self.ctx, perm.read_permission())?;
404406

405-
update_uncommited_changes(self.ctx, workspace_state, new_workspace, perm)?;
407+
update_uncommited_changes_with_tree(
408+
self.ctx,
409+
workspace_state,
410+
new_workspace,
411+
old_cwd,
412+
Some(true),
413+
perm,
414+
)?;
406415

407416
update_workspace_commit(&vb_state, self.ctx)?;
408417

0 commit comments

Comments
 (0)