Skip to content

fix: guard against nil remote branch pointers in GetRemoteBranchListDisplayStrings#5601

Open
troclaux wants to merge 1 commit into
jesseduffield:masterfrom
troclaux:fix/nil-check-remote-branch-display
Open

fix: guard against nil remote branch pointers in GetRemoteBranchListDisplayStrings#5601
troclaux wants to merge 1 commit into
jesseduffield:masterfrom
troclaux:fix/nil-check-remote-branch-display

Conversation

@troclaux
Copy link
Copy Markdown

Summary

Fixes #5370.

During concurrent remote refresh, stale nil pointers can appear in the branches slice. GetRemoteBranchListDisplayStrings calls branch.FullName() unconditionally, causing a nil pointer panic.

Fix: switch from lo.Map to lo.FilterMap and skip nil entries.

Changes

  • pkg/gui/presentation/remote_branches.go: use lo.FilterMap to skip nil branch pointers
  • pkg/gui/presentation/remote_branches_test.go: new test that passes a slice containing nil entries and asserts only non-nil branches produce display rows

Test plan

  • go test ./pkg/gui/presentation/... passes
  • New test TestGetRemoteBranchListDisplayStrings_NilBranch confirms nil entries are skipped without panic

During concurrent remote refresh, stale nil pointers can appear in the
branches slice, causing a panic in GetRemoteBranchListDisplayStrings when
branch.FullName() is called. Skip nil entries with lo.FilterMap instead
of lo.Map.

Fixes jesseduffield#5370
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nil pointer panic in GetRemoteBranchListDisplayStrings

1 participant