Skip to content

Panic: index out of range on startup with repo containing many tags on one commit #4765

@willbush

Description

@willbush

Describe the bug

I was trying to make a repro of what I think is a perf regression in lazygit somehow tied to having a git repo with a large number of tags 8k+ (I'll make another issue for that #4770). However, I stumbled on an index out of bounds panic on lazygit startup instead by doing the abnormal step of creating 8k git tags on one commit.

To Reproduce
Steps to reproduce the behavior:

Assuming access to bash:

  1. mkdir tester && cd tester
  2. git init && git commit --allow-empty -m "Initial commit"
  3. create 8k tags: for i in $(seq 1 8000); do git tag "v0.0.$i"; done takes a few seconds
  4. lazygit
  5. See error
❯ lazygit
panic: runtime error: index out of range [5] with length 5

goroutine 99 [running]:
github.com/jesseduffield/lazygit/pkg/commands/git_commands.(*CommitLoader).extractCommitFromLine(0x10000?, 0xc00014c6c0, {0xc000380000?, 0xc000990180?}, 0x0)
        github.com/jesseduffield/lazygit/pkg/commands/git_commands/commit_loader.go:208 +0x5d5
github.com/jesseduffield/lazygit/pkg/commands/git_commands.(*CommitLoader).GetCommits.func1.1({0xc000380000?, 0xc00036c000?})
        github.com/jesseduffield/lazygit/pkg/commands/git_commands/commit_loader.go:93 +0x48
github.com/jesseduffield/lazygit/pkg/commands/oscommands.(*cmdObjRunner).RunAndProcessLines(0xc0002b8770, 0xc000986140, 0xc0009cc000)
        github.com/jesseduffield/lazygit/pkg/commands/oscommands/cmd_obj_runner.go:172 +0x337
github.com/jesseduffield/lazygit/pkg/commands.(*gitCmdObjRunner).RunAndProcessLines(0x1?, 0x0?, 0x0?)
        github.com/jesseduffield/lazygit/pkg/commands/git_cmd_obj_runner.go:68 +0x1c
github.com/jesseduffield/lazygit/pkg/commands/oscommands.(*CmdObj).RunAndProcessLines(...)
        github.com/jesseduffield/lazygit/pkg/commands/oscommands/cmd_obj.go:186
github.com/jesseduffield/lazygit/pkg/commands/git_commands.(*CommitLoader).GetCommits.func1()
        github.com/jesseduffield/lazygit/pkg/commands/git_commands/commit_loader.go:92 +0x19f
github.com/jesseduffield/lazygit/pkg/commands/git_commands.(*CommitLoader).GetCommits.gowrap1.Safe.1()
        github.com/jesseduffield/lazygit/pkg/utils/utils.go:69 +0x13
github.com/jesseduffield/lazygit/pkg/utils.SafeWithError(0x0?)
        github.com/jesseduffield/lazygit/pkg/utils/utils.go:80 +0x56
github.com/jesseduffield/lazygit/pkg/utils.Safe(...)
        github.com/jesseduffield/lazygit/pkg/utils/utils.go:69
created by github.com/jesseduffield/lazygit/pkg/commands/git_commands.(*CommitLoader).GetCommits in goroutine 85
        github.com/jesseduffield/lazygit/pkg/commands/git_commands/commit_loader.go:89 +0x225

Expected behavior

Either an error telling me I'm doing stupid shit or handle it (not sure if reasonable)

Version info:

❯ lazygit --version
commit=, build date=, build source=nix, version=0.53.0, os=linux, arch=amd64, git version=2.50.0
❯ git --version
git version 2.50.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions