jesseduffield.lazygit/pkg
Stefan Haller 3df894ec92 Stage affected unstaged files when applying or reverting a patch
Unlike moving a patch to the index, applying or reverting a patch didn't
auto-stash, which means that applying a patch when there's a modified (but
unstaged) file in the working tree would error out with the message "error:
file1: does not match index", regardless of whether those modifications conflict
with the patch or not.

To fix this, we *could* add auto-stashing like we do for the "move patch to
index" command. However, in this case we rather simply stage the affected files
(after asking for confirmation). This has a few advantages:

- it only changes the staging state of those files that are contained in the
patch (whereas auto-stashing always changes all files to unstaged)
- it doesn't unnecessarily show a confirmation if none of the modified files are
affected by the patch
- if the patch conflicts with the modified files, the conflicts were "backwards"
("ours" was the patch, "theirs" the modified file); it is more logical if "ours"
is the current state of the file, and "theirs" is the patch.

It's a little unfortunate that the behavior isn't exactly the same as for "move
patch to index", but for that one we do need the auto-stash because of the
rebase that runs behind the scenes.
2025-07-02 16:19:06 +02:00
..
app Enable revive linter, and fix a bunch of warnings 2025-06-30 19:13:20 +02:00
cheatsheet Update to go 1.24 2025-03-08 14:53:54 -05:00
commands Drop stash when successfully unstashing files after moving patch to index 2025-07-02 16:19:06 +02:00
common Move NewDummyCommon to pkg/common 2025-05-06 09:43:26 +02:00
config Enable errorlint linter, and fix warnings 2025-06-30 18:30:11 +02:00
constants Make the links in the status panel point to the current version rather than master 2024-03-22 08:13:59 +01:00
env Support bare worktrees where worktree does not have its own .git file 2023-08-07 22:40:53 +10:00
fakes cleanup integration test code 2023-02-26 12:54:13 +11:00
gui Stage affected unstaged files when applying or reverting a patch 2025-07-02 16:19:06 +02:00
i18n Stage affected unstaged files when applying or reverting a patch 2025-07-02 16:19:06 +02:00
integration Stage affected unstaged files when applying or reverting a patch 2025-07-02 16:19:06 +02:00
jsonschema Enable intrange linter, and fix warnings 2025-06-30 18:30:11 +02:00
logs Remove secureexec package 2023-07-30 19:59:51 +10:00
snake Enable intrange linter, and fix warnings 2025-06-30 18:30:11 +02:00
tasks Enable revive linter, and fix a bunch of warnings 2025-06-30 19:13:20 +02:00
theme Highlight inactive selection in bold 2024-06-23 14:43:13 +02:00
updates Change direct access to Common.UserConfig to a getter 2024-08-18 10:24:52 +02:00
utils Enable revive linter, and fix a bunch of warnings 2025-06-30 19:13:20 +02:00