Hi,
In pkg/commands/git_commands/worktree_loader.go, the porcelain output parser accesses current.Head and current.Branch without checking if current is nil.
current starts as nil and is also set to nil after encountering a "bare" line. If git worktree list --porcelain produces unexpected output (e.g., a "HEAD" or "branch" line without a preceding "worktree" line — which can happen with corrupted git state or manual worktree directory manipulation), this will panic.
This might be related to some of the worktree crashes reported in #5266.
A simple nil check before each access would make the parser more defensive.
Hi,
In
pkg/commands/git_commands/worktree_loader.go, the porcelain output parser accessescurrent.Headandcurrent.Branchwithout checking ifcurrentis nil.currentstarts as nil and is also set to nil after encountering a "bare" line. Ifgit worktree list --porcelainproduces unexpected output (e.g., a "HEAD" or "branch" line without a preceding "worktree" line — which can happen with corrupted git state or manual worktree directory manipulation), this will panic.This might be related to some of the worktree crashes reported in #5266.
A simple nil check before each access would make the parser more defensive.