jesseduffield / lazygit

simple terminal UI for git commands
MIT License
52.34k stars 1.83k forks source link

I don't know how I did it, nor do I know what broke #3981

Open mahyarmirrashed opened 2 weeks ago

mahyarmirrashed commented 2 weeks ago

Describe the bug I was in the middle of cherry picking a commit from far back in history, doing some branch surgery.

To Reproduce Delete a lot of commits off of a new branch, and try to cherry pick a commit over from the old branch? That's what I did to get here.

Expected behavior Not to panic after I switch branches after I selected the commit to cherry pick with C.

Screenshots

(windtools-py3.10) mahyar@lioness python3-windtools % lazygit
panic: runtime error: index out of range [1] with length 1

goroutine 1926 [running]:
github.com/jesseduffield/lazygit/pkg/gui/context.searchModelCommits.func2(0x1000088?, 0x1065cdf08?)
        github.com/jesseduffield/lazygit/pkg/gui/context/local_commits_context.go:212 +0x124
github.com/samber/lo.FilterMap[...]({0x14000e18020, 0x3, 0x1057a2660}, 0x14001881a20?)
        github.com/samber/lo@v1.31.0/slice.go:45 +0x98
github.com/jesseduffield/lazygit/pkg/gui/context.searchModelCommits(0x60?, {0x14000e18020?, 0x14001881ac8?, 0x104e62134?}, {0x14000f84008?, 0x105f92100?, 0x14001881b38?}, {0x0?, 0x14000042230?})
        github.com/jesseduffield/lazygit/pkg/gui/context/local_commits_context.go:206 +0x80
github.com/jesseduffield/lazygit/pkg/gui/context.(*LocalCommitsContext).ModelSearchResults(0x1400012eab0, {0x0, 0x0}, 0x0)
        github.com/jesseduffield/lazygit/pkg/gui/context/local_commits_context.go:161 +0x6c
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.modelSearchResults({0x105919150, 0x1400012eab0})
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/search_helper.go:180 +0xb8
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*SearchHelper).ReApplySearch(0x140002a4620, {0x105918138, 0x1400012eab0})
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/search_helper.go:259 +0x84
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).refreshView(0x140001153c0, {0x105918138, 0x1400012eab0})
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:770 +0x70
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).refreshCommitsWithLimit(0x140001153c0)
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:347 +0x454
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).refreshCommitsAndCommitFiles(0x140001153c0)
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:278 +0x20
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).Refresh.func2.1.2()
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:116 +0x90
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).Refresh.func2.1.gowrap1.Safe.1()
        github.com/jesseduffield/lazygit/pkg/utils/utils.go:88 +0x24
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x14000072ef0?)
        github.com/jesseduffield/lazygit/pkg/utils/utils.go:99 +0x60
github.com/jesseduffield/lazygit/pkg/utils.Safe(...)
        github.com/jesseduffield/lazygit/pkg/utils/utils.go:88
created by github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).Refresh.func2.1 in goroutine 1
        github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:113 +0x128

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

stefanhaller commented 1 week ago

The current lazygit version is 0.44.1, and this bug is already fixed there (see #3838). Please keep your version up to date.