Skip to content

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

Open
xvchris wants to merge 3 commits 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 3 commits intogitui-org:masterfrom
xvchris:fix/remotelist-panic-no-remotes

Conversation

@xvchris
Copy link

@xvchris xvchris commented Mar 4, 2026

This Pull Request fixes/closes #2868, #2869.

It changes the following:

  • Add valid_selection() guard to rename_remote event handler branch
  • Add valid_selection() guard to update_remote_url event handler branch
  • Add changelog entry under ## Unreleased### Fixes

These guards match the existing pattern on delete_remote, preventing an index-out-of-bounds panic when the remote list is empty.

I followed the checklist:

  • I added unittests — RemoteListPopup has no existing test infrastructure (new() requires full Environment); the fix is a 2-line guard addition matching the existing delete_remote pattern
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

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.

Copy link
Collaborator

@extrawurst extrawurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. looks good to me. Please add a changelog entry and we are gtg

@extrawurst extrawurst added this to the v0.28.1 milestone Mar 5, 2026
@xvchris xvchris requested a review from extrawurst March 6, 2026 08:36
@xvchris xvchris force-pushed the fix/remotelist-panic-no-remotes branch 2 times, most recently from c0f5b29 to 30acb93 Compare March 6, 2026 08:45
@xvchris xvchris force-pushed the fix/remotelist-panic-no-remotes branch from 30acb93 to 5bbe31f Compare March 6, 2026 08:46
@xvchris
Copy link
Author

xvchris commented Mar 8, 2026

Hi @extrawurst, the changelog entry was already added in commit 25ab784. Please take another look when you get a chance! 🙏

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 crash in empty repo with no remotes

2 participants