Skip to content

Commit 235ab15

Browse files
committed
Don't auto-forward branches that are checked out by another worktree
1 parent 7130cb2 commit 235ab15

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

pkg/gui/controllers/helpers/branches_helper.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ func (self *BranchesHelper) AutoForwardBranches() error {
283283
updateCommands := ""
284284
// The first branch is the currently checked out branch; skip it
285285
for _, branch := range branches[1:] {
286-
if branch.RemoteBranchStoredLocally() && (allBranches || lo.Contains(self.c.UserConfig().Git.MainBranches, branch.Name)) {
286+
if branch.RemoteBranchStoredLocally() &&
287+
!self.checkedOutByOtherWorktree(branch) &&
288+
(allBranches || lo.Contains(self.c.UserConfig().Git.MainBranches, branch.Name)) {
287289
isStrictlyBehind := branch.IsBehindForPull() && !branch.IsAheadForPull()
288290
if isStrictlyBehind {
289291
updateCommands += fmt.Sprintf("update %s %s %s\n", branch.FullRefName(), branch.FullUpstreamRefName(), branch.CommitHash)

pkg/integration/tests/sync/fetch_and_auto_forward_branches_all_branches_checked_out_in_other_worktree.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ var FetchAndAutoForwardBranchesAllBranchesCheckedOutInOtherWorktree = NewIntegra
5151
Contains("checked-out").IsSelected(),
5252
Contains("diverged ↓2↑1"),
5353
Contains("feature ✓"),
54-
/* EXPECTED:
5554
Contains("master (worktree) ↓1"),
56-
ACTUAL: */
57-
Contains("master (worktree) ✓"),
5855
)
5956
},
6057
})

0 commit comments

Comments
 (0)