fix: guard rename/update_url actions against empty remote list#2870
Open
xvchris wants to merge 1 commit intogitui-org:masterfrom
Open
fix: guard rename/update_url actions against empty remote list#2870xvchris wants to merge 1 commit intogitui-org:masterfrom
xvchris wants to merge 1 commit intogitui-org:masterfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix panic (index out of bounds) in
RemoteListPopupwhen triggering rename or update-URL actions in a repository with no remotes configured.Problem
In
src/popups/remotelist.rs, therename_remote()andupdate_remote_url()methods directly index intoself.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:Fix
Add
self.valid_selection()guards to therename_remoteandupdate_remote_urlevent handler branches, matching the existing guard ondelete_remote.This is a minimal, consistent fix — the
valid_selection()helper already exists and correctly returnsfalsewhenremote_namesis empty.Testing
cargo check✓cargo fmt -- --check✓cargo clippy -p gitui -- -D warnings✓Fixes #2868
Fixes #2869