lazygit/pkg/integration/tests/interactive_rebase
Stefan Haller 8b99a3c949 Drop update-ref commands at the top of the rebase-todo file
The rebase.updateRefs feature of git is very useful to rebase a stack of
branches and keep everything nicely stacked; however, it is usually in the way
when you make a copy of a branch and want to rebase it "away" from the original
branch in some way or other. For example, the original branch might sit on main,
and you want to rebase the copy onto devel to see if things still compile there.
Or you want to do some heavy history rewriting experiments on the copy, but keep
the original branch in case the experiments fail. Or you want to split a branch
in two because it contains two unrelated sets of changes; so you make a copy,
and drop half of the commits from the copy, then check out the original branch
and drop the other half of the commits from it.

In all these cases, git's updateRefs feature insists on moving the original
branch along with the copy in the first rebase that you make on the copy. I
think this is a bug in git, it should create update-ref todos only for branches
that point into the middle of your branch (because only then do they form a
stack), not when they point at the head (because then it's a copy). I had a long
discussion about this on the git mailing list [1], but people either don't agree
or don't care enough.

So we fix this on our side: whenever we start a rebase for whatever reason, be
it interactive, non-interactive, or behind-the-scenes, we drop any update-ref
todos that are at the very top of the todo list, which fixes all the
above-mentioned scenarios nicely.

I will admit that there's one scenario where git's behavior is the desired one,
and the fix in this PR makes it worse: when you create a new branch off of an
existing one, with the intention of creating a stack of branches, but before you
make the first commit on the new branch you realize some problem with the first
branch (e.g. a commit that needs to be reworded or dropped). It this case you do
want both branches to be affected by the change. In my experience this scenario
is much rarer than the other ones that I described above, and it's also much
easier to recover from: just check out the other branch again and hard-reset it
to the rebased one.

[1]
https://public-inbox.org/git/354f9fed-567f-42c8-9da9-148a5e223022@haller-berlin.de/
2024-04-22 20:59:15 +02:00
..
advanced_interactive_rebase.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
amend_commit_with_conflict.go Insert fake todo entry for a conflicting commit that is being applied 2023-06-22 18:57:58 +02:00
amend_first_commit.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
amend_fixup_commit.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
amend_head_commit_during_rebase.go Improve prompts when amending commits 2023-09-01 18:55:16 +02:00
amend_merge.go Improve prompts when amending commits 2023-09-01 18:55:16 +02:00
amend_non_head_commit_during_rebase.go Use ErrorToast instead of error panel when invoking a disabled command 2024-01-14 17:45:35 +01:00
delete_update_ref_todo.go Fix deleting update-ref todos 2024-03-26 22:29:56 +01:00
dont_show_branch_heads_for_todo_items.go Don't show branch head on rebase todos if the rebase.updateRefs config is on 2024-03-02 10:17:58 +01:00
drop_commit_in_copied_branch_with_update_ref.go Drop update-ref commands at the top of the rebase-todo file 2024-04-22 20:59:15 +02:00
drop_todo_commit_with_update_ref.go Don't show branch head on rebase todos if the rebase.updateRefs config is on 2024-03-02 10:17:58 +01:00
drop_with_custom_comment_char.go Support range select in rebase actions 2024-01-23 17:23:56 +11:00
edit_first_commit.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
edit_non_todo_commit_during_rebase.go Support range select in rebase actions 2024-01-23 17:23:56 +11:00
edit_range_select_outside_rebase.go Support setting a range of commits to "edit" outside of a rebase 2024-03-09 07:43:48 +01:00
edit_the_confl_commit.go Support range select in rebase actions 2024-01-23 17:23:56 +11:00
fixup_first_commit.go Use ErrorToast instead of error panel when invoking a disabled command 2024-01-14 17:45:35 +01:00
fixup_second_commit.go Support range select in rebase actions 2024-01-23 17:23:56 +11:00
interactive_rebase_of_copied_branch.go Drop update-ref commands at the top of the rebase-todo file 2024-04-22 20:59:15 +02:00
mid_rebase_range_select.go Support setting a range of commits to "edit" outside of a rebase 2024-03-09 07:43:48 +01:00
move.go Support range select in rebase actions 2024-01-23 17:23:56 +11:00
move_in_rebase.go Support range select in rebase actions 2024-01-23 17:23:56 +11:00
move_update_ref_todo.go Allow moving update-ref todos up/down 2024-03-16 22:01:03 +01:00
move_with_custom_comment_char.go Use comment char config on interactive rebase 2023-07-02 02:07:32 -03:00
outside_rebase_range_select.go Support range select in rebase actions 2024-01-23 17:23:56 +11:00
pick_rescheduled.go Add test for a pick that fails and gets rescheduled 2023-06-22 18:57:43 +02:00
quick_start.go Allow showing Disabled errors as error panel instead of toast 2024-01-14 17:45:35 +01:00
quick_start_keep_selection.go Don't show branch head on rebase todos if the rebase.updateRefs config is on 2024-03-02 10:17:58 +01:00
quick_start_keep_selection_range.go Don't show branch head on rebase todos if the rebase.updateRefs config is on 2024-03-02 10:17:58 +01:00
rebase.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
reword_commit_with_editor_and_fail.go Add test for rewording a commit and failing with an error 2023-06-22 18:57:43 +02:00
reword_first_commit.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
reword_last_commit.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
reword_you_are_here_commit.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
reword_you_are_here_commit_with_editor.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
shared.go Insert fake todo entry for a conflicting commit that is being applied 2023-06-22 18:57:58 +02:00
squash_down_first_commit.go Use ErrorToast instead of error panel when invoking a disabled command 2024-01-14 17:45:35 +01:00
squash_down_second_commit.go Support range select in rebase actions 2024-01-23 17:23:56 +11:00
squash_fixups_above.go Make it easy to create "amend!" commits 2024-03-22 08:27:45 +01:00
squash_fixups_above_first_commit.go Make it easy to create "amend!" commits 2024-03-22 08:27:45 +01:00
squash_fixups_in_current_branch.go Keep the same line selected after squashing fixup commits 2024-03-09 07:55:22 +01:00
swap_in_rebase_with_conflict.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
swap_in_rebase_with_conflict_and_edit.go Add a test for stopping at an "edit" command that conflicts 2023-06-22 18:57:58 +02:00
swap_with_conflict.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
view_files_of_todo_entries.go Don't show branch head on rebase todos if the rebase.updateRefs config is on 2024-03-02 10:17:58 +01:00