From 06a3f660b255c52f5934323d16fb43ab753e231a Mon Sep 17 00:00:00 2001 From: xvchris <56232580+xvchris@users.noreply.github.com> Date: Fri, 20 Mar 2026 06:51:09 +0800 Subject: [PATCH] fix: guard rename/update_url actions against empty remote list (#2870) * fix: guard rename/update_url actions against empty remote list 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 #2868 Fixes #2869 * chore: add changelog entry and sort Cargo.toml dependencies * revert: restore original Cargo.toml formatting --- CHANGELOG.md | 3 +++ src/popups/remotelist.rs | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8d86b65..f9ccb915 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * rust msrv bumped to `1.88` +### Fixed +* fix panic when renaming or updating remote URL with no remotes configured [[@xvchris](https://github.com/xvchris)] ([#2868](https://github.com/gitui-org/gitui/issues/2868)) + ## [0.28.0] - 2025-12-14 **discard changes on checkout** diff --git a/src/popups/remotelist.rs b/src/popups/remotelist.rs index 7f14f77d..c09986ae 100644 --- a/src/popups/remotelist.rs +++ b/src/popups/remotelist.rs @@ -146,12 +146,14 @@ impl Component for RemoteListPopup { } else if key_match( e, self.key_config.keys.update_remote_name, - ) { + ) && self.valid_selection() + { self.rename_remote(); } else if key_match( e, self.key_config.keys.update_remote_url, - ) { + ) && self.valid_selection() + { self.update_remote_url(); } }