jesseduffield / lazygit

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

View upstream during rebasing causing crash #3900

Closed Saafo closed 5 days ago

Saafo commented 2 weeks ago

Describe the bug View upstream during rebasing causing crash

To Reproduce Steps to reproduce the behavior:

  1. Rebase and the branch state is at no branch, rebasing xx(e.g. main)
  2. View divergence from upstream on main
  3. Lazygit crash

Expected behavior Can see divergence

Screenshots Will upload if needed.

Version info: commit=, build date=, build source=homebrew, version=0.44.0, os=darwin, arch=arm64, git version=2.45.2 git version 2.45.2

Additional context

Crash stack ```text panic: runtime error: index out of range [0] with length 0 goroutine 1 [running]: github.com/jesseduffield/lazygit/pkg/gui/context.(*ListRenderer).insertNonModelItems(0x0?, {0x140009ac260, 0x2, 0x0?}, 0x14, 0x0, {0x105819420?, 0x104bd45d8?, 0x104fb0380?}, {0x0, ...}) github.com/jesseduffield/lazygit/pkg/gui/context/list_renderer.go:124 +0x31c github.com/jesseduffield/lazygit/pkg/gui/context.(*ListRenderer).renderLines(0x14000157eb0, 0x0, 0x14) github.com/jesseduffield/lazygit/pkg/gui/context/list_renderer.go:96 +0x1d4 github.com/jesseduffield/lazygit/pkg/gui/context.(*ListContextTrait).HandleRender(0x14000157ea0) github.com/jesseduffield/lazygit/pkg/gui/context/list_context_trait.go:105 +0xdc github.com/jesseduffield/lazygit/pkg/gui.(*Gui).postRefreshUpdate(0x14000121208, {0x10513c890, 0x1400017e2a0}) github.com/jesseduffield/lazygit/pkg/gui/view_helpers.go:135 +0x88 github.com/jesseduffield/lazygit/pkg/gui.(*guiCommon).PostRefreshUpdate(0x14000138078?, {0x10513c890?, 0x1400017e2a0?}) github.com/jesseduffield/lazygit/pkg/gui/gui_common.go:33 +0x28 github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*SubCommitsHelper).ViewSubCommits(0x1400000cd38, {{0x1051303e0, 0x14000e3e0c0}, {0x14000138090, 0x16}, {0x14000138078, 0x12}, {0x10513c078, 0x14000031ae0}, 0x0}) github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/sub_commits_helper.go:70 +0x468 github.com/jesseduffield/lazygit/pkg/gui/controllers.(*BranchesController).viewUpstreamOptions.func1() github.com/jesseduffield/lazygit/pkg/gui/controllers/branches_controller.go:206 +0x1b8 github.com/jesseduffield/lazygit/pkg/gui/context.(*MenuContext).OnMenuPress(0x14000088820?, 0x140001aa0e0) github.com/jesseduffield/lazygit/pkg/gui/context/menu_context.go:206 +0x128 github.com/jesseduffield/lazygit/pkg/gui/controllers.(*MenuController).press(0x140000318e0?, 0x140001aa0e0) github.com/jesseduffield/lazygit/pkg/gui/controllers/menu_controller.go:72 +0x40 github.com/jesseduffield/lazygit/pkg/gui/controllers.(*MenuController).GetKeybindings.(*ListControllerTrait[...]).withItem.func4() github.com/jesseduffield/lazygit/pkg/gui/controllers/list_controller_trait.go:116 +0x48 github.com/jesseduffield/lazygit/pkg/gui.(*Gui).callKeybindingHandler(0x14000121208, 0x14000cef2c0?) github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:465 +0x11c github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.func1() github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:412 +0x24 github.com/jesseduffield/lazygit/pkg/gui.(*Gui).SetKeybinding.(*Gui).wrappedHandler.func3(0x140013594a8?, 0x10463abcc?) github.com/jesseduffield/lazygit/pkg/gui/keybindings.go:406 +0x24 github.com/jesseduffield/gocui.(*Gui).execKeybinding(0x14001359630?, 0x2?, 0x3ae05c700b3?) github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:1529 +0x6c github.com/jesseduffield/gocui.(*Gui).execKeybindings(0x14000102c40, 0x140000c6200, 0x140013595b0) github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:1497 +0x398 github.com/jesseduffield/gocui.(*Gui).onKey(0x140000a2628?, 0x14001359530?) github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:1308 +0x170 github.com/jesseduffield/gocui.(*Gui).handleEvent(0x140000a2600?, 0x14001359598?) github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:842 +0x54 github.com/jesseduffield/gocui.(*Gui).processEvent(0x14000102c40) github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:796 +0x180 github.com/jesseduffield/gocui.(*Gui).MainLoop(0x14000102c40) github.com/jesseduffield/gocui@v0.3.1-0.20240906064314-bfab49c720d7/gui.go:775 +0xf0 github.com/jesseduffield/lazygit/pkg/gui.(*Gui).Run(0x14000121208, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}}) github.com/jesseduffield/lazygit/pkg/gui/gui.go:846 +0x424 github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError.func1() github.com/jesseduffield/lazygit/pkg/gui/gui.go:852 +0x40 github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x1400012d360?) github.com/jesseduffield/lazygit/pkg/utils/utils.go:99 +0x5c github.com/jesseduffield/lazygit/pkg/gui.(*Gui).RunAndHandleError(0x14000121208, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}}) github.com/jesseduffield/lazygit/pkg/gui/gui.go:851 +0xac github.com/jesseduffield/lazygit/pkg/app.(*App).Run(...) github.com/jesseduffield/lazygit/pkg/app/app.go:270 github.com/jesseduffield/lazygit/pkg/app.Run({0x105135698?, 0x14000122370?}, 0x1400013d740, {{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}}) github.com/jesseduffield/lazygit/pkg/app/app.go:48 +0x9c github.com/jesseduffield/lazygit/pkg/app.Start(0x14000045ef8, {0x0, 0x0}) github.com/jesseduffield/lazygit/pkg/app/entry_point.go:167 +0x98c main.main() github.com/jesseduffield/lazygit/main.go:23 +0x98 ```

Note: please try updating to the latest version or manually building the latest master to see if the issue still occurs.

stefanhaller commented 2 weeks ago

I have seen this crash too, but wasn't able to reliably reproduce it yet. Trying your reproduction steps doesn't result in a crash for me.

There must be more conditions to making it crash; something about where the current selection in the commits panel is, or how long the divergence log is, or something like that. It would be great if you could narrow it down some more.

Saafo commented 1 week ago

Ohh I forgot one thing, when rebasing, there're some files in conflicts. In my case, there is a single file in conflicts.