lazygit/pkg/integration/tests
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
..
bisect Deprecate git.log.showGraph and git.log.order config 2024-02-16 13:23:35 +01:00
branch Drop update-ref commands at the top of the rebase-todo file 2024-04-22 20:59:15 +02:00
cherry_pick Deprecate git.log.showGraph and git.log.order config 2024-02-16 13:23:35 +01:00
commit Make it easy to create "amend!" commits 2024-03-22 08:27:45 +01:00
config Support matchers on integers in integration tests 2023-06-03 15:32:23 +10:00
conflicts Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
custom_commands pkg: fix some typos 2024-04-20 13:47:39 +02:00
demo Update interactive rebase demo 2024-03-23 20:45:51 +11:00
diff Add busy count for integration tests 2023-07-08 22:54:52 +10:00
file Support range select for staging/discarding files 2024-01-25 11:34:59 +11:00
filter_and_search Fix crash when filtering the keybindings menu 2024-03-28 09:58:45 +01:00
filter_by_author Add author filtering to commit view 2024-02-21 09:58:09 +01:00
filter_by_path Keep the same commit selected when exiting filtering mode 2024-03-28 12:23:46 +01:00
interactive_rebase Drop update-ref commands at the top of the rebase-todo file 2024-04-22 20:59:15 +02:00
misc Change CopiedToClipboard text to start lower-case 2024-03-22 09:59:46 +01:00
patch_building Add integration test 2024-02-18 15:24:09 +01:00
reflog Deprecate git.log.showGraph and git.log.order config 2024-02-16 13:23:35 +01:00
shared Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
staging Add range selection ability on list contexts 2024-01-19 10:47:21 +11:00
stash feat: add age on stash lines 2023-12-27 11:21:49 +01:00
submodule Show all submodules recursively 2024-03-07 20:16:28 +01:00
sync Keep same branch selected when refreshing branches 2024-01-19 09:25:07 +01:00
tag Make it possible to handle toasts in integration tests 2024-01-14 17:42:03 +01:00
ui Show mode-specific keybinding suggestions 2024-01-28 08:33:13 +11:00
undo Support range select in rebase actions 2024-01-23 17:23:56 +11:00
worktree pkg: fix some typos 2024-04-20 13:47:39 +02:00
test_list.go Add tests demonstrating undesired behavior with update-ref todos for copied branches 2024-04-22 20:59:15 +02:00
test_list_generator.go Make test_list_generator.go print what it's doing 2023-09-29 20:40:15 +02:00
tests.go Set working directory in lazygit test command 2024-01-12 19:59:31 +11:00