jesseduffield / lazygit

simple terminal UI for git commands
MIT License
50.95k stars 1.79k forks source link

Crash view divergence from upstream #3917

Closed bomgar closed 5 days ago

bomgar commented 6 days ago

Describe the bug

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListRenderer).insertNonModelItems(0x0?, {0xc000d89a10, 0x2, 0x1?}, 0xe, 0x0, {0x5e7f88957040?, 0xc001b3eef0?, 0xffffffffffffffff?}, {0x0, ...})
        github.com/jesseduffield/lazygit/pkg/gui/context/list_renderer.go:124 +0x370
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListRenderer).renderLines(0xc0003e06f0, 0x0, 0xe)
        github.com/jesseduffield/lazygit/pkg/gui/context/list_renderer.go:96 +0x23c
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListContextTrait).HandleRender(0xc0003e06e0)
        github.com/jesseduffield/lazygit/pkg/gui/context/list_context_trait.go:105 +0xd7
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).postRefreshUpdate(0xc000380008, {0x5e7f88261370, 0xc0002b6e40})
        github.com/jesseduffield/lazygit/pkg/gui/view_helpers.go:135 +0xaf
github.com/jesseduffield/lazygit/pkg/gui.(*guiCommon).PostRefreshUpdate(0xc0003d3ce0?, {0x5e7f88261370?, 0xc0002b6e40?})
        github.com/jesseduffield/lazygit/pkg/gui/gui_common.go:33 +0x25
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*SubCommitsHelper).ViewSubCommits(0xc000012fc0, {{0x5e7f88254fa0, 0xc001876180}, {0xc0001530c0, 0x1a}, {0xc0003d3ce0, 0x18}, {0x5e7f88260b58, 0xc0002db260}, 0x0})
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/sub_commits_helper.go:70 +0x57b
github.com/jesseduffield/lazygit/pkg/gui/controllers.(*BranchesController).viewUpstreamOptions.func1()
        github.com/jesseduffield/lazygit/pkg/gui/controllers/branches_controller.go:206 +0x267
github.com/jesseduffield/lazygit/pkg/gui/context.(*MenuContext).OnMenuPress(0xc00013e7a0?, 0xc0001d40e0)
        github.com/jesseduffield/lazygit/pkg/gui/context/menu_context.go:206 +0x11e
github.com/jesseduffield/lazygit/pkg/gui/controllers.(*MenuController).press(0xc0002db060?, 0xc0001d40e0)
        github.com/jesseduffield/lazygit/pkg/gui/controllers/menu_controller.go:72 +0x36
github.com/jesseduffield/lazygit/pkg/gui/controllers.(*MenuController).GetKeybindings.(*ListControllerTrait[...]).withItem.func4()
        github.com/jesseduffield/lazygit/pkg/gui/controllers/list_controller_trait.go:116 +0x3b
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).callKeybindingHandler(0xc000380008, 0xc0002e6f00?)
        github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:465 +0x104
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.func1()
        github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:412 +0x1b
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.(*Gui).wrappedHandler.func3(0x5e7f8772c9ce?, 0xc001b3f4d8?)
        github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:406 +0x13
github.com/jesseduffield/gocui.(*Gui).execKeybinding(0x5e7f877088f2?, 0xc001b3f650?, 0x2?)
        github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:1529 +0x4a
github.com/jesseduffield/gocui.(*Gui).execKeybindings(0xc000104a80, 0xc0001cc400, 0xc001b3f5d0)
        github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:1497 +0x3e5
github.com/jesseduffield/gocui.(*Gui).onKey(0xc0001f4058?, 0xc001b3f558?)
        github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:1308 +0x1de
github.com/jesseduffield/gocui.(*Gui).handleEvent(0xc0001f4030?, 0xc001b3f5b8?)
        github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:842 +0x39
github.com/jesseduffield/gocui.(*Gui).processEvent(0xc000104a80)
        github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:796 +0x226
github.com/jesseduffield/gocui.(*Gui).MainLoop(0xc000104a80)
        github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:775 +0xd7
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0xc000380008, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:846 +0x4f1
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1()
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:852 +0x45
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0xc0000b3440?)
        github.com/jesseduffield/lazygit/pkg/utils/utils.go:99 +0x56
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0xc000380008, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/jesseduffield/lazygit/pkg/gui/gui.go:851 +0xce
github.com/jesseduffield/lazygit/pkg/app.(*App).Run(...)
        github.com/jesseduffield/lazygit/pkg/app/app.go:270
github.com/jesseduffield/lazygit/pkg/app.Run({0x5e7f8825a298?, 0xc0002a2210?}, 0xc0000c1480, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}})
        github.com/jesseduffield/lazygit/pkg/app/app.go:48 +0xd6
github.com/jesseduffield/lazygit/pkg/app.Start(0xc00004df00, {0x0, 0x0})
        github.com/jesseduffield/lazygit/pkg/app/entry_point.go:167 +0xcdc
main.main()
        github.com/jesseduffield/lazygit/main.go:23 +0x98

To Reproduce

View divergence from upstream: Compare master with origin master. No actual divergence

Screenshots 2024-09-16-200307_grim

Version info: commit=v0.44.0, build date=2024-09-07T08:46:08Z, build source=binaryRelease, version=0.44.0, os=linux, arch=amd64, git version=2.46.1 git version 2.46.1

stefanhaller commented 6 days ago

Thanks for the report. This is a duplicate of #3900, but the added information "No actual divergence" helped me reproduce it (what a stupid bug). Here's a fix: #3918.

stefanhaller commented 5 days ago

Fixed by #3918.