From aee21ca17f5408f0fddb839ba60f79485eae385d Mon Sep 17 00:00:00 2001 From: Ryan Hawkins Date: Wed, 10 Sep 2025 18:20:32 -0600 Subject: [PATCH] Allow for commit amends with no file changes (#37256) This will users to change the wording of the most recent commit, something they might want to do if they realize they made a small typo of some kind or if the formatting of their commit message is wrong, but don't have any other changes they need to make. Release Notes: - Commit messages can now be amended in the UI without any other changes needing to be made. --------- Co-authored-by: Cole Miller --- crates/git_ui/src/git_panel.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 31c3f5e77ace726ec42998977d623d3d77b20c5d..d746c1dc60e1061086e0673fc3e5675f97817cf6 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -1709,7 +1709,7 @@ impl GitPanel { .map(|status_entry| status_entry.repo_path.clone()) .collect::>(); - if changed_files.is_empty() { + if changed_files.is_empty() && !options.amend { error_spawn("No changes to commit", window, cx); return; } @@ -3295,7 +3295,7 @@ impl GitPanel { pub fn configure_commit_button(&self, cx: &mut Context) -> (bool, &'static str) { if self.has_unstaged_conflicts() { (false, "You must resolve conflicts before committing") - } else if !self.has_staged_changes() && !self.has_tracked_changes() { + } else if !self.has_staged_changes() && !self.has_tracked_changes() && !self.amend_pending { (false, "No changes to commit") } else if self.pending_commit.is_some() { (false, "Commit in progress") @@ -3312,8 +3312,10 @@ impl GitPanel { if self.amend_pending { if self.has_staged_changes() { "Amend" - } else { + } else if self.has_tracked_changes() { "Amend Tracked" + } else { + "Amend" } } else if self.has_staged_changes() { "Commit"