From 235ab15d7b59fb5d8652b20279542e4e3ddeeb7b Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 18 Aug 2025 18:21:45 +0200 Subject: [PATCH] Don't auto-forward branches that are checked out by another worktree --- pkg/gui/controllers/helpers/branches_helper.go | 4 +++- ...ard_branches_all_branches_checked_out_in_other_worktree.go | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/gui/controllers/helpers/branches_helper.go b/pkg/gui/controllers/helpers/branches_helper.go index 8760c4366..5566dc40c 100644 --- a/pkg/gui/controllers/helpers/branches_helper.go +++ b/pkg/gui/controllers/helpers/branches_helper.go @@ -283,7 +283,9 @@ func (self *BranchesHelper) AutoForwardBranches() error { updateCommands := "" // The first branch is the currently checked out branch; skip it for _, branch := range branches[1:] { - if branch.RemoteBranchStoredLocally() && (allBranches || lo.Contains(self.c.UserConfig().Git.MainBranches, branch.Name)) { + if branch.RemoteBranchStoredLocally() && + !self.checkedOutByOtherWorktree(branch) && + (allBranches || lo.Contains(self.c.UserConfig().Git.MainBranches, branch.Name)) { isStrictlyBehind := branch.IsBehindForPull() && !branch.IsAheadForPull() if isStrictlyBehind { updateCommands += fmt.Sprintf("update %s %s %s\n", branch.FullRefName(), branch.FullUpstreamRefName(), branch.CommitHash) diff --git a/pkg/integration/tests/sync/fetch_and_auto_forward_branches_all_branches_checked_out_in_other_worktree.go b/pkg/integration/tests/sync/fetch_and_auto_forward_branches_all_branches_checked_out_in_other_worktree.go index e0913fb0e..bc1ecd294 100644 --- a/pkg/integration/tests/sync/fetch_and_auto_forward_branches_all_branches_checked_out_in_other_worktree.go +++ b/pkg/integration/tests/sync/fetch_and_auto_forward_branches_all_branches_checked_out_in_other_worktree.go @@ -51,10 +51,7 @@ var FetchAndAutoForwardBranchesAllBranchesCheckedOutInOtherWorktree = NewIntegra Contains("checked-out").IsSelected(), Contains("diverged ↓2↑1"), Contains("feature ✓"), - /* EXPECTED: Contains("master (worktree) ↓1"), - ACTUAL: */ - Contains("master (worktree) ✓"), ) }, })