1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-17 01:42:45 +02:00

Fix possible crash with auto-forwarding branches

I'm not aware of any real scenario where this can happen, but we have seen one
stack trace where it crashed with an out-of-bounds error in the range expression
below, so there must be a way. And it seems better to guard against it anyway,
rather than assuming it can't happen.
This commit is contained in:
Stefan Haller
2025-05-15 21:21:44 +02:00
parent 43efdded4a
commit 01b63a25ba

View File

@ -270,8 +270,12 @@ func (self *BranchesHelper) AutoForwardBranches() error {
return nil
}
allBranches := self.c.UserConfig().Git.AutoForwardBranches == "allBranches"
branches := self.c.Model().Branches
if len(branches) == 0 {
return nil
}
allBranches := self.c.UserConfig().Git.AutoForwardBranches == "allBranches"
updateCommands := ""
// The first branch is the currently checked out branch; skip it
for _, branch := range branches[1:] {