Skip to content

Conversation

@stefanhaller
Copy link
Collaborator

  • PR Description

This is part three of a four part series of PRs that improve the cherry-pick and revert experience.

With this PR we reimplement copy/paste of commits to use git cherry-pick under the hood. We do this because

  • it's closer to what you would do on the command line
  • it simplifies the code a bit
  • it allows us to support cherry-picking merge commits.

Fixes #1374
Fixes #3317

  • 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

@stefanhaller stefanhaller added the enhancement New feature or request label Mar 31, 2025
@stefanhaller stefanhaller force-pushed the show-revert-and-cherry-pick-todos branch from cd2e83f to a8eefbc Compare March 31, 2025 17:39
@stefanhaller stefanhaller force-pushed the implement-cherry-picking-with-git-cherry-pick branch 2 times, most recently from d81bb8b to e30f7b4 Compare March 31, 2025 19:19
@codacy-production
Copy link

codacy-production bot commented Mar 31, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for b7d01d61 97.44%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (b7d01d6) Report Missing Report Missing Report Missing
Head commit (108054e) 55015 47770 86.83%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4443) 78 76 97.44%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@stefanhaller stefanhaller force-pushed the show-revert-and-cherry-pick-todos branch from a8eefbc to d88dd37 Compare April 5, 2025 09:26
@stefanhaller stefanhaller force-pushed the implement-cherry-picking-with-git-cherry-pick branch from e30f7b4 to 3ff8f5c Compare April 5, 2025 09:26
@stefanhaller stefanhaller force-pushed the show-revert-and-cherry-pick-todos branch from d88dd37 to 57d7c9e Compare April 7, 2025 12:42
@stefanhaller stefanhaller force-pushed the implement-cherry-picking-with-git-cherry-pick branch from 3ff8f5c to fb458bb Compare April 7, 2025 12:43
@stefanhaller stefanhaller force-pushed the show-revert-and-cherry-pick-todos branch from 57d7c9e to c1143a2 Compare April 10, 2025 09:53
@stefanhaller stefanhaller force-pushed the implement-cherry-picking-with-git-cherry-pick branch from fb458bb to 417080e Compare April 10, 2025 09:53
@stefanhaller stefanhaller force-pushed the show-revert-and-cherry-pick-todos branch from c1143a2 to b350876 Compare April 20, 2025 13:56
Base automatically changed from show-revert-and-cherry-pick-todos to master April 20, 2025 13:58
…ing new ones

Previously we would create new Commit objects to store in the CherryPicking mode
which only contained a name and hash, all other fields were unset. I'm not sure
why we did this; it's easier to just reference the original commits. Later on
this branch we will need this because we need to determine whether a copied
commit was a merge commit (by looking at its Parents field).
We do this because
- it's closer to what you would do on the command line
- it simplifies the code a bit
- it will allow us to support cherry-picking merge commits.
Now that we use git cherry-pick to implement it, there's no reason not to.
@stefanhaller stefanhaller force-pushed the implement-cherry-picking-with-git-cherry-pick branch from 417080e to 108054e Compare April 20, 2025 13:59
@stefanhaller stefanhaller enabled auto-merge April 20, 2025 14:00
@stefanhaller stefanhaller merged commit c13c635 into master Apr 20, 2025
14 checks passed
@stefanhaller stefanhaller deleted the implement-cherry-picking-with-git-cherry-pick branch April 20, 2025 14:02
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 10, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | minor | `v0.48.0` -> `v0.50.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary>

### [`v0.50.0`](https://github.com/jesseduffield/lazygit/releases/tag/v0.50.0)

[Compare Source](jesseduffield/lazygit@v0.49.0...v0.50.0)

<!-- Release notes generated using configuration in .github/release.yml at v0.50.0 -->

#### What's Changed

##### Enhancements 🔥

-   Continue/abort a conflicted cherry-pick or revert by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4441
-   Show todo items for pending cherry-picks and reverts by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4442
-   Use "git cherry-pick" for implementing copy/paste of commits by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4443
-   Allow reverting a range of commits by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4444
-   Section headers for rebase todos and actual commits by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4463
-   Focus the main view by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4429
-   Auto-forward main branches after fetching by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4493
-   Add new command "Move commits to new branch" by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#3876
-   Strip the '+' and '-' characters when copying parts of a diff to the clipboard by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4519
-   Reduce memory consumption of graph (pipe sets) by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4498

##### Fixes 🔧

-   Fix truncation of branches when scrolling branches panel to the left by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4483
-   Fix nvim-remote commands for fish shell by [@&#8203;SavingFrame](https://github.com/SavingFrame) in jesseduffield/lazygit#4506
-   Disallow creating custom patches when the diff context size is 0 by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4522
-   Remove double space between rebase todo and author columns by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4520

##### Maintenance ⚙️

-   Allow closing issues via github actions by [@&#8203;jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4515

##### Docs 📖

-   Add Debian installation instructions alongside Ubuntu by [@&#8203;jmkim](https://github.com/jmkim) in jesseduffield/lazygit#4501
-   fix wording of random tip by [@&#8203;dawedawe](https://github.com/dawedawe) in jesseduffield/lazygit#4488

#### New Contributors

-   [@&#8203;jmkim](https://github.com/jmkim) made their first contribution in jesseduffield/lazygit#4501
-   [@&#8203;SavingFrame](https://github.com/SavingFrame) made their first contribution in jesseduffield/lazygit#4506
-   [@&#8203;dawedawe](https://github.com/dawedawe) made their first contribution in jesseduffield/lazygit#4488

**Full Changelog**: jesseduffield/lazygit@v0.49.0...v0.50.0

### [`v0.49.0`](https://github.com/jesseduffield/lazygit/releases/tag/v0.49.0)

[Compare Source](jesseduffield/lazygit@v0.48.0...v0.49.0)

<!-- Release notes generated using configuration in .github/release.yml at v0.49.0 -->

#### What's Changed

##### Enhancements 🔥

-   Support fish when running shell command by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4350
-   Add acme editor preset by [@&#8203;rakoo](https://github.com/rakoo) in jesseduffield/lazygit#4360
-   Support home and end as alternatives to '<' and '>' by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4396
-   Drop the git config cache when getting focus by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4376
-   Add a "Content of selected file" entry to the copy menu for commit files by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4341
-   Add root node in file tree by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4346
-   \[FEAT] Add Recursive Bulk Initialize and Update for Submodules by [@&#8203;cesarandr](https://github.com/cesarandr) in jesseduffield/lazygit#4259
-   Commit without pre-commit hooks action is independent on prefix by [@&#8203;kschweiger](https://github.com/kschweiger) in jesseduffield/lazygit#4374
-   Let users define custom icons and color for files on the config file by [@&#8203;hasecilu](https://github.com/hasecilu) in jesseduffield/lazygit#4395
-   Add "Absolute path" item to the file view's copy menu by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4410
-   Allow range drop stashes by [@&#8203;gaogao-qwq](https://github.com/gaogao-qwq) in jesseduffield/lazygit#4451
-   More navigation keybindings for confirmation panel by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4404
-   Resolve non-inline merge conflicts by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4431
-   Add `runCommand` function to Go template syntax + add support for templates in git `branchPrefix` setting by [@&#8203;ruudk](https://github.com/ruudk) in jesseduffield/lazygit#4438
-   Show "(hooks disabled)" in title bar of commit message editor by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4467
-   Add a command to select all commits of the current branch by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4448

##### Fixes 🔧

-   Use a waiting status for rewording a non-head commit by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4343
-   Fix layout of options view for non-english languages by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4359
-   Fix changing language while lazygit is running by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4361
-   URL encode gitlab brackets to make consistent with branch names by [@&#8203;ChrisMcD1](https://github.com/ChrisMcD1) in jesseduffield/lazygit#4336
-   Fix commitPrefix setting with empty pattern by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4381
-   Commit only tracked files in tracked filter view by [@&#8203;parthokunda](https://github.com/parthokunda) in jesseduffield/lazygit#4386
-   Revert [#&#8203;4313](jesseduffield/lazygit#4313) (Skip post-checkout hook when discarding changes) by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4407
-   Enhance support for GPG signed tags by [@&#8203;ChrisMcD1](https://github.com/ChrisMcD1) in jesseduffield/lazygit#4394
-   Fix checking out a file from a range selection of commits by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4423
-   Fix discarding submodule changes in nested folders by [@&#8203;brandondong](https://github.com/brandondong) in jesseduffield/lazygit#4317
-   Better support for shell aliases by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4385
-   Fix hyperlinks in last line of confirmation popups by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4454
-   Fix wrong main view content after pressing `e` in a stack of branches by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4450
-   fix: update vscode color to logo color by [@&#8203;PeterCardenas](https://github.com/PeterCardenas) in jesseduffield/lazygit#4459
-   Fix crash with drag selecting and staging by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4480
-   Escape special characters in filenames when git-ignoring files by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4475

##### Maintenance ⚙️

-   Fix linter warnings by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4352
-   Fix release schedule again by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4364
-   Update to go 1.24 by [@&#8203;radsaq](https://github.com/radsaq) in jesseduffield/lazygit#4377
-   Add an integration test for a config with a negative refspec by [@&#8203;radsaq](https://github.com/radsaq) in jesseduffield/lazygit#4382
-   Specify a go release minor version by [@&#8203;radsaq](https://github.com/radsaq) in jesseduffield/lazygit#4393
-   Fix flaky integration test by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4432
-   Some code cleanup by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4449
-   Bump the minimum required git version to 2.22 by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4439
-   Bump go-git, and get rid of github.com/imdario/mergo by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4460
-   Skip date check when release worfklow is manually invoked by [@&#8203;jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4484

##### Docs 📖

-   Include empty arrays and maps in config docs by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4413
-   Filter out deprecated user config fields from generated Config.md by [@&#8203;karimkhaleel](https://github.com/karimkhaleel) in jesseduffield/lazygit#4416
-   Corrected interactive rebase keybind example in README.md by [@&#8203;NewtonChutney](https://github.com/NewtonChutney) in jesseduffield/lazygit#4426
-   Update kidpix link in README to active url by [@&#8203;ChrisMcD1](https://github.com/ChrisMcD1) in jesseduffield/lazygit#4425

##### I18n 🌎

-   Update translation files from Crowdin by [@&#8203;stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4473

#### New Contributors

-   [@&#8203;rakoo](https://github.com/rakoo) made their first contribution in jesseduffield/lazygit#4360
-   [@&#8203;radsaq](https://github.com/radsaq) made their first contribution in jesseduffield/lazygit#4377
-   [@&#8203;cesarandr](https://github.com/cesarandr) made their first contribution in jesseduffield/lazygit#4259
-   [@&#8203;kschweiger](https://github.com/kschweiger) made their first contribution in jesseduffield/lazygit#4374
-   [@&#8203;NewtonChutney](https://github.com/NewtonChutney) made their first contribution in jesseduffield/lazygit#4426
-   [@&#8203;gaogao-qwq](https://github.com/gaogao-qwq) made their first contribution in jesseduffield/lazygit#4451
-   [@&#8203;ruudk](https://github.com/ruudk) made their first contribution in jesseduffield/lazygit#4438

**Full Changelog**: jesseduffield/lazygit@v0.48.0...v0.49.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xMS4yIiwidXBkYXRlZEluVmVyIjoiNDAuMTEuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
stefanhaller added a commit that referenced this pull request Jul 4, 2025
…4683)

- **PR Description**

For cherry-picking, this used to work in earlier versions, but it broke
in #4443. For reverting, it was never supported.

Also, we add some minor improvements while we're at it, such as slightly
better names for the auto-stashes that are created for the various
operations (so that, if an auto-stash pop fails and the stash is kept
around, you can tell more easily what it was for). Also, we now adjust
the selection of the commits list after cherry-picking, so that the same
commit stays selected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use "git cherry-pick" instead of interactive rebase to implement cherry-picking Error when cherry-picking a merge commit

2 participants