Skip to content

Conversation

kosiew
Copy link

@kosiew kosiew commented Oct 1, 2025

Closes: #4763


PR Description

This PR improves lazygit's handling of cherry-pick operations that result in an empty commit (i.e., the commit makes no changes to the working tree). In such cases, Git allows the user to either skip the commit or create an empty one using --allow-empty. Prior to this patch, lazygit would freeze or leave the UI in an unresolved state when this happened.

This update introduces:

  • Detection of empty cherry-pick states during the cherry-pick flow.
  • A GUI prompt asking the user whether to skip the commit or continue by creating an empty one.
  • Seamless continuation of cherry-picking even when multiple commits are being cherry-picked and one or more are empty.
  • Integration with Git 2.45+ behavior using --empty=stop.
  • Associated changes in i18n and test coverage to ensure robust support.

This improves UX by removing the need to drop to the command line during edge-case cherry-pick flows.


Please check if the PR fulfills these requirements


Additional Notes:

  • Introduces --empty=stop for Git >= 2.45 to halt on empty commits for cherry-pick operations.
  • Adds new translation keys for user prompts.
  • Ensures that post-paste UI cleanup and state restoration happens correctly.
  • Covers all edge cases with integration tests: single empty commit, range with empty commit, followed by conflict, auto-stash interaction, and user decision paths.

This ensures a smooth and intuitive cherry-pick workflow, even in complex scenarios — all within the lazygit UI ✨

kosiew added 30 commits October 1, 2025 19:58
- Update README to describe new behavior for cherry-picking empty commits.
- Implement CommitAllowEmpty method to allow creating empty commits.
- Modify cherry-pick error handling to prompt user for action on empty cherry-picks.
- Add translations for new prompts in multiple languages.
- Introduce integration test for cherry-picking a commit with no changes.
…ng tree state before proceeding with commands
…s with user prompts and integrate tests for empty commit resolutions
…inuing rebase and update revert test to select create empty commit option
…dling and remove redundant checks for merge conflicts
…s and improve error handling for empty commits
… handling and remove redundant conflict check
…ing to improve clarity and reduce redundancy
…add support for "equals one of" matcher in tests
…ick scenarios and improve popup interactions
…s and improve handling of empty commits in tests
…post-paste selection and improve handling after empty cherry-pick resolution
kosiew added 12 commits October 1, 2025 19:58
…ct and update test assertions for empty commits
…lution to preserve post-paste reselect option
…disable post-paste reselect and improve test assertions for conflict scenarios
- Updated `CherryPickHelper` to modify the `postPasteCleanup` function to accept a boolean parameter indicating whether to mark the paste operation.
- Added `postPasteShouldMarkDidPaste` field to manage the state of whether to mark as done after pasting.
- Adjusted the logic in several methods (`Paste`, `runPostPasteCleanup`, etc.) to handle the new parameter appropriately.
- Updated integration tests to reflect changes in expected behavior for cherry-picking during rebase and empty autostash scenarios.
…king and add integration tests for empty intermediate commits
@kosiew kosiew force-pushed the cherry-freeze-4763 branch from 9168622 to 2677cfd Compare October 1, 2025 12:09
@kosiew kosiew marked this pull request as ready for review October 8, 2025 05:19
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