diff --git a/pkg/gui/controllers/helpers/branches_helper.go b/pkg/gui/controllers/helpers/branches_helper.go index a53bf2181..8af447f79 100644 --- a/pkg/gui/controllers/helpers/branches_helper.go +++ b/pkg/gui/controllers/helpers/branches_helper.go @@ -286,12 +286,14 @@ func (self *BranchesHelper) deleteRemoteBranches(remoteBranches []*models.Remote } func (self *BranchesHelper) PostFetchRefresh(fetchErr error) error { - self.c.Refresh(types.RefreshOptions{ - Scope: []types.RefreshableView{ - types.BRANCHES, types.COMMITS, types.REMOTES, types.TAGS, types.PULL_REQUESTS, - }, - Mode: types.SYNC, - }) + scope := []types.RefreshableView{ + types.BRANCHES, types.COMMITS, types.REMOTES, types.TAGS, types.PULL_REQUESTS, + } + // AutoForwardBranches needs a fresh worktree model to skip branches that are checked out elsewhere. + if self.c.UserConfig().Git.AutoForwardBranches != "none" { + scope = append(scope, types.WORKTREES) + } + self.c.Refresh(types.RefreshOptions{Scope: scope, Mode: types.SYNC}) if fetchErr != nil { return fetchErr } diff --git a/pkg/integration/tests/sync/fetch_and_auto_forward_branches_worktree_added_after_startup.go b/pkg/integration/tests/sync/fetch_and_auto_forward_branches_worktree_added_after_startup.go index 61cb0fd9f..bee14276a 100644 --- a/pkg/integration/tests/sync/fetch_and_auto_forward_branches_worktree_added_after_startup.go +++ b/pkg/integration/tests/sync/fetch_and_auto_forward_branches_worktree_added_after_startup.go @@ -43,12 +43,8 @@ var FetchAndAutoForwardBranchesWorktreeAddedAfterStartup = NewIntegrationTest(Ne t.Views().Branches(). Lines( Contains("feature").IsSelected(), - /* EXPECTED: Contains("master (worktree linked-worktree) ↓1"), Contains("wt-branch").DoesNotContain("worktree"), - ACTUAL: */ - Contains("master ✓"), - Contains("wt-branch (worktree linked-worktree)"), ) t.Views().Worktrees(). @@ -58,11 +54,6 @@ var FetchAndAutoForwardBranchesWorktreeAddedAfterStartup = NewIntegrationTest(Ne t.Views().Files(). Focus(). - /* EXPECTED: IsEmpty() - ACTUAL: */ - Lines( - Equals("D file03.txt"), - ) }, })