jesseduffield.lazygit/pkg/integration/tests/branch
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
..
checkout_by_name.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
create_tag.go Better tag creation UX 2023-07-22 14:36:35 +10:00
delete.go Use ErrorToast instead of error panel when invoking a disabled command 2024-01-14 17:45:35 +01:00
delete_remote_branch_with_credential_prompt.go Add integration test for deleting a remote branch with credentials prompt 2023-09-20 13:29:30 +02:00
detached_head.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
open_pull_request_no_upstream.go Use UpstreamBranch for opening pull requests 2023-09-18 13:40:52 +10:00
open_with_cli_arg.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
rebase.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
rebase_abort_on_conflict.go Show menu instead of prompt when there are conflicts in a rebase or merge 2023-06-01 10:51:48 +02:00
rebase_and_drop.go Insert fake todo entry for a conflicting commit that is being applied 2023-06-22 18:57:58 +02:00
rebase_cancel_on_conflict.go Show menu instead of prompt when there are conflicts in a rebase or merge 2023-06-01 10:51:48 +02:00
rebase_copied_branch.go Drop update-ref commands at the top of the rebase-todo file 2024-04-22 20:59:15 +02:00
rebase_does_not_autosquash.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
rebase_from_marked_base.go Add rebase from marked base commit test 2023-08-12 16:16:03 +10:00
rebase_to_upstream.go Use ErrorToast instead of error panel when invoking a disabled command 2024-01-14 17:45:35 +01:00
rename.go Replace whitespace with '-' when renaming a branch 2023-09-05 14:57:18 +01:00
reset.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
reset_to_upstream.go Use ErrorToast instead of error panel when invoking a disabled command 2024-01-14 17:45:35 +01:00
set_upstream.go chore: rename "Set/Unset upstream" menu to "Upstream Options" 2023-09-06 00:23:35 +02:00
show_divergence_from_upstream.go chore: rename "Set/Unset upstream" menu to "Upstream Options" 2023-09-06 00:23:35 +02:00
sort_local_branches.go Add integration test for local branch sort order 2023-12-27 15:25:29 +01:00
sort_remote_branches.go Add integration test for remote branch sort order 2023-12-22 16:30:20 +09:00
suggestions.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
unset_upstream.go Fix unsetting upstream when it doesn't exist 2023-11-04 23:46:27 +01:00