Skip to content

fix: guard rename/update_url actions against empty remote list#2870

Open
xvchris wants to merge 1 commit intogitui-org:masterfrom
xvchris:fix/remotelist-panic-no-remotes
Open

fix: guard rename/update_url actions against empty remote list#2870
xvchris wants to merge 1 commit intogitui-org:masterfrom
xvchris:fix/remotelist-panic-no-remotes

Conversation

@xvchris
Copy link

@xvchris xvchris commented Mar 4, 2026

Summary

Fix panic (index out of bounds) in RemoteListPopup when triggering rename or update-URL actions in a repository with no remotes configured.

Problem

In src/popups/remotelist.rs, the rename_remote() and update_remote_url() methods directly index into self.remote_names[self.selection as usize] without first checking whether the list is empty. When a user opens the remote list popup in a repo with no remotes and presses the rename or update-URL keybinding, GitUI panics:

panicked at src/popups/remotelist.rs:460:30:
index out of bounds: the len is 0 but the index is 0

Fix

Add self.valid_selection() guards to the rename_remote and update_remote_url event handler branches, matching the existing guard on delete_remote.

This is a minimal, consistent fix — the valid_selection() helper already exists and correctly returns false when remote_names is empty.

Testing

  • cargo check
  • cargo fmt -- --check
  • cargo clippy -p gitui -- -D warnings

Fixes #2868
Fixes #2869

The rename_remote() and update_remote_url() event handlers in
RemoteListPopup did not check valid_selection() before indexing
into self.remote_names, causing a panic (index out of bounds)
when no remotes are configured.

The delete_remote() handler already had this guard. This commit
adds the same valid_selection() check to the other two handlers
for consistency.

Fixes gitui-org#2868
Fixes gitui-org#2869
xvchris

This comment was marked as abuse.

xvchris

This comment was marked as abuse.

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.

GitUI panics in RemoteList with no remotes configured ("git: inconclusive remotes") GitUI crash in empty repo with no remotes

1 participant