Skip to content

Commit 220cde1

Browse files
committed
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.)
1 parent 19f8829 commit 220cde1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/commands/git_commands/branch.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ func (self *BranchCommands) allBranchesLogCandidates() []string {
278278
func (self *BranchCommands) AllBranchesLogCmdObj() *oscommands.CmdObj {
279279
candidates := self.allBranchesLogCandidates()
280280

281+
if self.allBranchesLogCmdIndex >= len(candidates) {
282+
self.allBranchesLogCmdIndex = 0
283+
}
284+
281285
i := self.allBranchesLogCmdIndex
282286
return self.cmd.New(str.ToArgv(candidates[i])).DontLog()
283287
}

0 commit comments

Comments
 (0)