jesseduffield.lazygit/pkg/utils
Stefan Haller 1fdcc29277 Fix deleting update-ref todos
It is a bad idea to read a git-rebase-todo file, remove some update-ref todos,
and write it back out behind git's back. This will cause git to actually remove
the branches referenced by those update-ref todos when the rebase is continued.

The reason is that git remembers the refs affected by update-ref todos at the
beginning of the rebase, and remembers information about them in the file
.git/rebase-merge/update-refs. Then, whenever the user performs a "git rebase
--edit-todo" command, it updates that file based on whether update-ref todos
were added or removed by that edit. If we rewrite the git-rebase-todo file
behind git's back, this updating doesn't happen.

Fix this by not updating the git-rebase-todo file directly in this case, but
performing a "git rebase --edit-todo" command where we set ourselves as the
editor and change the file in there. This makes git update the bookkeeping
information properly.

Ideally we would use this method for all cases where we change the
git-rebase-todo file (e.g. moving todos up/down, or changing the type of a
todo); this would be cleaner because we wouldn't mess with git's private
implementation details. I tried this, but unfortunately it isn't fast enough.
Right now, moving a todo up or down takes between 1 and 2ms on my machine;
changing it to do a "git rebase --edit-todo" slows it down to over 100ms, which
is unacceptable.
2024-03-26 22:29:56 +01:00
..
yaml_utils Avoid rewriting the file if nothing changed 2023-06-26 08:11:10 +02:00
color.go feat: accept named colors for gui.authorColors 2022-05-04 19:03:00 +09:00
color_test.go update linters 2022-03-19 12:12:57 +11:00
date.go Use 'M' for months in branches panel 2023-07-30 18:35:22 +10:00
date_test.go Fix unit tests 2023-07-30 18:35:23 +10:00
dummies.go Add AppState to common.Common 2023-09-04 17:48:39 +02:00
errors.go move OS commands into their own package 2020-09-29 20:48:49 +10:00
formatting.go Support range select for staging/discarding files 2024-01-25 11:34:59 +11:00
formatting_test.go Make columnPositions include entries for removed columns 2023-08-28 14:21:06 +02:00
history_buffer.go Add search history 2023-09-20 08:35:41 +03:00
history_buffer_test.go Add search history 2023-09-20 08:35:41 +03:00
io.go refactor 2021-06-02 20:33:52 +10:00
lines.go fix: fix stash with empty message 2022-10-13 22:23:56 +09:00
lines_test.go fix: fix stash with empty message 2022-10-13 22:23:56 +09:00
once_writer.go add deadlock mutex package 2022-08-07 11:16:14 +10:00
once_writer_test.go add deadlock mutex package 2022-08-07 11:16:14 +10:00
rebase_todo.go Fix deleting update-ref todos 2024-03-26 22:29:56 +01:00
rebase_todo_test.go Allow deleting update-ref todos 2024-03-16 22:01:13 +01:00
regexp.go add FindNamedMatches function in utils 2021-12-26 16:48:23 +11:00
regexp_test.go add FindNamedMatches function in utils 2021-12-26 16:48:23 +11:00
search.go Rename FuzzySearch to FilterStrings 2024-03-17 11:55:30 +01:00
search_test.go Rename FuzzySearch to FilterStrings 2024-03-17 11:55:30 +01:00
slice.go Standardise on using lo for slice functions 2023-07-30 18:51:23 +10:00
slice_test.go Make moving todo commits more robust 2023-04-15 08:36:03 +02:00
string_stack.go start refactoring gui 2022-03-17 19:13:40 +11:00
template.go fix: fix ReplacePlaceholderString 2023-01-18 20:56:22 +09:00
template_test.go fix: fix ReplacePlaceholderString 2023-01-18 20:56:22 +09:00
thread_safe_map.go use thread safe map 2022-10-02 20:57:44 -07:00
thread_safe_map_test.go use thread safe map 2022-10-02 20:57:44 -07:00
utils.go Rename MinMax to SortRange 2024-01-26 11:18:06 +01:00
utils_test.go refactor to only have one context per view 2022-08-06 13:49:11 +10:00