-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Describe the bug
Lazygit crashed/ panicked with a invalid memory address or nil pointer dereference error, after deleting a remote branch.
To Reproduce
Steps to reproduce the behavior:
- Create a remote branch with a name 'zzz' (a name that alphabetically will be the last one in the list.)
- In lazygit go to the
Remotes, and press enter to show the list of all remote branches. - Use the filter
/zzzand search for the remote - Delete the branch (press 'd' and enter.)
lazygit crashes with:
goroutine 1182 [running]:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x10 pc=0x9c8b0b]
goroutine 827 [running]:
github.com/jesseduffield/lazygit/pkg/commands/models.(*RemoteBranch).FullName(...)
/home/runner/work/lazygit/lazygit/pkg/commands/models/remote_branch.go:10
github.com/jesseduffield/lazygit/pkg/gui/presentation.GetRemoteBranchListDisplayStrings.func1(0x0, 0x1ab0a5b0501?)
/home/runner/work/lazygit/lazygit/pkg/gui/presentation/remote_branches.go:12 +0x2b
github.com/samber/lo.Map[...]({0xc000154300?, 0x10, 0xc0000c4b00}, 0xc000a47c50?)
/home/runner/work/lazygit/lazygit/vendor/github.com/samber/lo/slice.go:29 +0x68
github.com/jesseduffield/lazygit/pkg/gui/presentation.GetRemoteBranchListDisplayStrings({0xc000154300?, 0xc000808200?, 0xc0000c4b00?}, {0x0?, 0x9e0a8a?})
/home/runner/work/lazygit/lazygit/pkg/gui/presentation/remote_branches.go:11 +0x5d
github.com/jesseduffield/lazygit/pkg/gui/context.NewRemoteBranchesContext.func3(0xc0003adc80?, 0xc000906100?)
/home/runner/work/lazygit/lazygit/pkg/gui/context/remote_branches_context.go:31 +0x72
github.com/jesseduffield/lazygit/pkg/gui/context.(*ListContextTrait).HandleRender(0xc0003add80)
/home/runner/work/lazygit/lazygit/pkg/gui/context/list_context_trait.go:90 +0x8d
github.com/jesseduffield/lazygit/pkg/gui.(*Gui).postRefreshUpdate(0xc0002bab00, {0xdef710, 0xc00049c858})
/home/runner/work/lazygit/lazygit/pkg/gui/view_helpers.go:139 +0xd8
github.com/jesseduffield/lazygit/pkg/gui.(*guiCommon).PostRefreshUpdate(0xc00038ed40?, {0xdef710?, 0xc00049c858?})
/home/runner/work/lazygit/lazygit/pkg/gui/gui_common.go:32 +0x26
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).refreshRemotes(0xc00009a480)
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:622 +0x1e5
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).Refresh.func2.8()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:153 +0x1d
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).Refresh.func2.1.2()
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:108 +0xc5
github.com/jesseduffield/lazygit/pkg/utils.Safe.func1()
/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:97 +0x1b
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x421685?)
/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:108 +0x67
github.com/jesseduffield/lazygit/pkg/utils.Safe(0xc000b0d160?)
/home/runner/work/lazygit/lazygit/pkg/utils/utils.go:97 +0x35
created by github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).Refresh.func2.1
/home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:105 +0x156
The branch was successfully deleted, but the crash was not expected.
My conjecture is that the filter uses an index in the list of remote branches. It showed the last branch from the list, and deleting that resulted in filter trying to use an index that no longer is in the list of remote branches.
Expected behavior
I expected lazygit to continue, and probably redo the filter operation to look what are the most likely candidates.
Screenshots
If applicable, add screenshots to help explain your problem.
Version info:
Run lazygit --version and paste the result here
commit=5e388e21c8ca6aa883dbcbe45c47f6fdd5116815, build date=2023-08-07T14:05:48Z, build source=binaryRelease, version=0.40.2, os=windows, arch=amd64, git version=2.41.0.windows.3
Run git --version and paste the result here
git version 2.41.0.windows.3
Additional context
Note: please try updating to the latest version or manually building the latest master to see if the issue still occurs.