jesseduffield.lazygit/pkg/integration/tests/patch_building
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
..
apply.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
apply_in_reverse.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
apply_in_reverse_with_conflict.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
apply_with_modified_file_conflict.go Stage affected unstaged files when applying or reverting a patch 2025-07-02 16:19:06 +02:00
apply_with_modified_file_no_conflict.go Stage affected unstaged files when applying or reverting a patch 2025-07-02 16:19:06 +02:00
edit_line_in_patch_building_panel.go Adjust line number for working copy when editing a line 2025-01-07 17:46:51 +01:00
move_range_to_index.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
move_to_earlier_commit.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00
move_to_earlier_commit_from_added_file.go Mention which command is continued in PromptToContinueRebase 2025-04-20 15:53:17 +02:00
move_to_earlier_commit_no_keep_empty.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00
move_to_index.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
move_to_index_from_added_file_with_conflict.go Mention which command is continued in PromptToContinueRebase 2025-04-20 15:53:17 +02:00
move_to_index_part_of_adjacent_added_lines.go Bump gocui 2025-01-07 17:34:30 +01:00
move_to_index_partial.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
move_to_index_with_conflict.go Mention which command is continued in PromptToContinueRebase 2025-04-20 15:53:17 +02:00
move_to_index_with_modified_file.go Drop stash when successfully unstashing files after moving patch to index 2025-07-02 16:19:06 +02:00
move_to_index_works_even_if_noprefix_is_set.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
move_to_later_commit.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00
move_to_later_commit_partial_hunk.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00
move_to_new_commit.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
move_to_new_commit_before.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
move_to_new_commit_before_no_keep_empty.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
move_to_new_commit_from_added_file.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
move_to_new_commit_from_deleted_file.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
move_to_new_commit_in_last_commit_of_stacked_branch.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
move_to_new_commit_partial_hunk.go Add custom patch command "Move patch into new commit before the original commit" 2025-05-10 18:57:28 +02:00
remove_from_commit.go Always render diffs to the main/secondary context pair, even for files 2025-04-21 18:03:18 +02:00
remove_parts_of_added_file.go Fix custom patch operations on added files 2024-06-23 12:40:31 +02:00
reset_with_escape.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
select_all_files.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00
specific_selection.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00
start_new_patch.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
toggle_range.go Add a root item ("/") if files at top level have changed 2025-03-21 08:04:58 +01:00