@@ -18,7 +18,7 @@ use gitbutler_repo::RepositoryExt as _;
18
18
use gitbutler_repo_actions:: RepoActionsExt ;
19
19
use gitbutler_stack:: { BranchOwnershipClaims , Stack , StackId } ;
20
20
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 } ;
22
22
#[ allow( deprecated) ]
23
23
use tracing:: instrument;
24
24
@@ -122,6 +122,7 @@ impl BranchManager<'_> {
122
122
pr_number : Option < usize > ,
123
123
perm : & mut WorktreeWritePermission ,
124
124
) -> Result < StackId > {
125
+ let old_cwd = self . ctx . repo ( ) . create_wd_tree ( 0 ) ?. id ( ) ;
125
126
let old_workspace = WorkspaceState :: create ( self . ctx , perm. read_permission ( ) ) ?;
126
127
// only set upstream if it's not the default target
127
128
let upstream_branch = match upstream_branch {
@@ -252,7 +253,7 @@ impl BranchManager<'_> {
252
253
) ?;
253
254
self . ctx . add_branch_reference ( & branch) ?;
254
255
255
- match self . apply_branch ( branch. id , perm, old_workspace) {
256
+ match self . apply_branch ( branch. id , perm, old_workspace, old_cwd ) {
256
257
Ok ( _) => Ok ( branch. id ) ,
257
258
Err ( err)
258
259
if err
@@ -275,6 +276,7 @@ impl BranchManager<'_> {
275
276
stack_id : StackId ,
276
277
perm : & mut WorktreeWritePermission ,
277
278
workspace_state : WorkspaceState ,
279
+ old_cwd : git2:: Oid ,
278
280
) -> Result < String > {
279
281
let repo = self . ctx . repo ( ) ;
280
282
@@ -402,7 +404,14 @@ impl BranchManager<'_> {
402
404
403
405
let new_workspace = WorkspaceState :: create ( self . ctx , perm. read_permission ( ) ) ?;
404
406
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
+ ) ?;
406
415
407
416
update_workspace_commit ( & vb_state, self . ctx ) ?;
408
417
0 commit comments