Skip to content

feat: restore commit message when undoing commits#5691

Open
chirino wants to merge 1 commit into
jesseduffield:masterfrom
chirino:restore-commit-message-on-undo
Open

feat: restore commit message when undoing commits#5691
chirino wants to merge 1 commit into
jesseduffield:masterfrom
chirino:restore-commit-message-on-undo

Conversation

@chirino

@chirino chirino commented Jun 12, 2026

Copy link
Copy Markdown

PR Description

Summary

Undoing a commit should leave the user as close as possible to the moment before they pressed commit. This change makes that workflow smoother by restoring the undone commit’s message into the commit panel after the soft reset, so the user can immediately review, tweak, and recommit without reconstructing the message manually.

Changes

  • Preserve the commit message from the undone commit when the undo action corresponds to a real commit.
  • Store the restored message using Lazygit’s existing LAZYGIT_PENDING_COMMIT draft mechanism, so subject/body behavior stays consistent with normal commit-message preservation.
  • Clear the restored message when the commit is redone, preventing stale messages from leaking into later commits.
  • Extend the undo integration test to verify staged changes remain available and the previous subject/body reappear in the commit panel.

Why

A soft reset already puts the committed changes back into a recommittable state, but losing the commit message makes “undo, adjust, recommit” more expensive than it needs to be. Preserving the message completes that workflow: the content and intent of the commit both come back together.

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

Signed-off-by: Hiram Chirino <hiram@hiramchirino.com>
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.

1 participant