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:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user