mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-27 23:08:02 +02:00
Fix possible crash with auto-forwarding branches (#4565)
- **PR Description** Fix crash in AutoForwardBranches when the branches slice is empty. 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. (Hopefully) fixes #4564.
This commit is contained in:
commit
1fbfefa625
@ -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:] {
|
||||
|
Loading…
x
Reference in New Issue
Block a user