feat(git): use soft reset to keep changes staged on undo

Change undo-last-commit behavior to perform a soft reset instead of a
mixed reset. This preserves the index and working tree so the undone
commit's changes remain staged and ready to recommit. The confirmation
dialog text was updated to accurately reflect the new behavior.

- Perform git reset --soft HEAD~1 to move HEAD while preserving index
- Update UI confirmation copy to state that changes remain staged and
  files are preserved
This commit is contained in:
2026-09-11 11:51:33 +02:00
parent 5c39fa3e30
commit eb4346fce2
2 changed files with 4 additions and 5 deletions
+3 -4
View File
@@ -2615,10 +2615,9 @@ pub fn undo_last_commit(path: String) -> Result<GitStatus, String> {
return Err("This is the first commit; there is nothing to undo to.".to_string());
}
// Mixed reset: moves HEAD back one commit and unstages the difference, but
// leaves the working tree files untouched, so the undone commit's changes
// reappear as ordinary uncommitted changes instead of being discarded.
run_git(&repo, ["reset", "HEAD~1"])?;
// Soft reset: moves HEAD back one commit while preserving the index and
// working tree, so the undone commit's changes remain staged.
run_git(&repo, ["reset", "--soft", "HEAD~1"])?;
status_for_repo(&repo)
}
+1 -1
View File
@@ -4719,7 +4719,7 @@
async function undoLastCommitChange() {
if (!activeRepoPath || !canAmend || isBusy) return;
const confirmed = window.confirm(
"Undo the last commit?\n\nIts changes come back as uncommitted changes in the working tree — nothing is discarded.",
"Undo the last commit?\n\nIts changes remain staged, ready to commit again. Your working tree files are preserved.",
);
if (!confirmed) return;