From cf372ec2e5f766f6a4f68196af926200bf6e289f Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 7 Oct 2025 17:22:56 +0200 Subject: [PATCH] Fix potential crash when reloading the config after removing a branch log command When cycling to the last branch log command, and then editing the config to remove one or more log commands, lazygit would crash with an out of bounds panic when returning to it. Fix this by resetting the log index to 0 when it is out of bounds. (I think resetting to 0 is better than clamping, although it doesn't matter much.) --- pkg/commands/git_commands/branch.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/commands/git_commands/branch.go b/pkg/commands/git_commands/branch.go index 37a661748..4a2fbd51f 100644 --- a/pkg/commands/git_commands/branch.go +++ b/pkg/commands/git_commands/branch.go @@ -278,6 +278,10 @@ func (self *BranchCommands) allBranchesLogCandidates() []string { func (self *BranchCommands) AllBranchesLogCmdObj() *oscommands.CmdObj { candidates := self.allBranchesLogCandidates() + if self.allBranchesLogCmdIndex >= len(candidates) { + self.allBranchesLogCmdIndex = 0 + } + i := self.allBranchesLogCmdIndex return self.cmd.New(str.ToArgv(candidates[i])).DontLog() }