1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-24 19:39:16 +02:00

Don't auto-forward branches that are checked out by another worktree

This commit is contained in:
Stefan Haller
2025-08-18 18:21:45 +02:00
parent 7130cb2947
commit 235ab15d7b
2 changed files with 3 additions and 4 deletions

View File

@@ -283,7 +283,9 @@ func (self *BranchesHelper) AutoForwardBranches() error {
updateCommands := "" updateCommands := ""
// The first branch is the currently checked out branch; skip it // The first branch is the currently checked out branch; skip it
for _, branch := range branches[1:] { 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() isStrictlyBehind := branch.IsBehindForPull() && !branch.IsAheadForPull()
if isStrictlyBehind { if isStrictlyBehind {
updateCommands += fmt.Sprintf("update %s %s %s\n", branch.FullRefName(), branch.FullUpstreamRefName(), branch.CommitHash) updateCommands += fmt.Sprintf("update %s %s %s\n", branch.FullRefName(), branch.FullUpstreamRefName(), branch.CommitHash)

View File

@@ -51,10 +51,7 @@ var FetchAndAutoForwardBranchesAllBranchesCheckedOutInOtherWorktree = NewIntegra
Contains("checked-out").IsSelected(), Contains("checked-out").IsSelected(),
Contains("diverged ↓2↑1"), Contains("diverged ↓2↑1"),
Contains("feature ✓"), Contains("feature ✓"),
/* EXPECTED:
Contains("master (worktree) ↓1"), Contains("master (worktree) ↓1"),
ACTUAL: */
Contains("master (worktree) ✓"),
) )
}, },
}) })