lazygit/pkg/commands/git_commands
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
..
bisect.go Centralise logic for obtaining repo paths 2023-07-30 18:35:24 +10:00
bisect_info.go Standardise on using lo for slice functions 2023-07-30 18:51:23 +10:00
blame.go Add command to find base commit for creating a fixup 2024-01-10 09:11:40 +01:00
branch.go When checking out a remote branch by name, ask the user how 2024-03-17 07:53:38 +01:00
branch_loader.go Add a sort order menu for local branches 2023-12-27 15:25:29 +01:00
branch_loader_test.go Add a sort order menu for local branches 2023-12-27 15:25:29 +01:00
branch_test.go Break git.merging.args config into separate arguments on whitespace 2024-03-02 10:22:01 +01:00
commit.go Make it easy to create "amend!" commits 2024-03-22 08:27:45 +01:00
commit_file_loader.go Set diff.noprefix=false for all other diff commands too 2024-02-18 15:22:43 +01:00
commit_file_loader_test.go Merge loaders package into git_commands package 2022-11-14 18:11:45 +11:00
commit_loader.go Store full ref in Name field of update-ref commits 2024-03-16 15:48:34 +01:00
commit_loader_test.go Deprecate git.log.showGraph and git.log.order config 2024-02-16 13:23:35 +01:00
commit_test.go Make it easy to create "amend!" commits 2024-03-22 08:27:45 +01:00
common.go Remove sync mutex 2023-10-08 18:45:36 +02:00
config.go Add UserConfig jsonschema generation script 2023-12-02 10:46:24 +01:00
custom.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
deps_test.go Add AppState to common.Common 2023-09-04 17:48:39 +02:00
diff.go Set diff.noprefix=false for all other diff commands too 2024-02-18 15:22:43 +01:00
file.go Support editing multiple files at once using range selection 2024-03-22 08:20:16 +01:00
file_loader.go Write unit tests with the help of afero 2023-07-30 18:35:36 +10:00
file_loader_test.go Write unit tests with the help of afero 2023-07-30 18:35:36 +10:00
file_test.go Support editing multiple files at once using range selection 2024-03-22 08:20:16 +01:00
flow.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
flow_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
git_command_builder.go Show all submodules recursively 2024-03-07 20:16:28 +01:00
git_command_builder_test.go Add worktree tests for removing/detaching 2023-07-30 18:35:23 +10:00
patch.go Fix problems with patches if git diff was customized with config. 2024-02-18 15:22:43 +01:00
rebase.go Fix deleting update-ref todos 2024-03-26 22:29:56 +01:00
rebase_test.go Support range select removing files from a commit 2024-02-13 09:10:15 -06:00
reflog_commit_loader.go Add author filtering to commit view 2024-02-21 09:58:09 +01:00
reflog_commit_loader_test.go Add author filtering to commit view 2024-02-21 09:58:09 +01:00
remote.go Obtain remote URL by calling "ls-remote --get-url" instead of using git config 2024-01-10 09:24:23 +01:00
remote_loader.go Implement a sort order menu for remote branches 2023-12-22 16:30:20 +09:00
repo_paths.go Refactor repo_paths.go to use git rev-parse 2024-01-24 08:40:01 +01:00
repo_paths_test.go Refactor repo_paths.go to use git rev-parse 2024-01-24 08:40:01 +01:00
stash.go Refactor repo_paths.go to use git rev-parse 2024-01-24 08:40:01 +01:00
stash_loader.go chore: use null char as a stash entries divider during loading 2023-12-27 11:21:49 +01:00
stash_loader_test.go feat: add age on stash lines 2023-12-27 11:21:49 +01:00
stash_test.go Refactor repo_paths.go to use git rev-parse 2024-01-24 08:40:01 +01:00
status.go Add StatusCommands.IsInNormalRebase and IsInInteractiveRebase 2023-09-18 10:50:19 +02:00
submodule.go Show all submodules recursively 2024-03-07 20:16:28 +01:00
sync.go Allow multiple fetch commands (or fetch and pull) to run concurrently 2024-01-10 09:18:38 +01:00
sync_test.go Use an interface for tasks instead of a concrete struct 2023-07-10 17:12:21 +10:00
tag.go Remove sync mutex 2023-10-08 18:45:36 +02:00
tag_loader.go Standardise on using lo for slice functions 2023-07-30 18:51:23 +10:00
tag_loader_test.go Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
version.go Add a method GitVersion.IsAtLeast 2024-01-10 09:18:38 +01:00
version_test.go Add a method GitVersion.IsAtLeast 2024-01-10 09:18:38 +01:00
working_tree.go Show all submodules recursively 2024-03-07 20:16:28 +01:00
working_tree_test.go Set diff.noprefix=false for all other diff commands too 2024-02-18 15:22:43 +01:00
worktree.go Centralise logic for obtaining repo paths 2023-07-30 18:35:24 +10:00
worktree_loader.go Refactor repo_paths.go to use git rev-parse 2024-01-24 08:40:01 +01:00
worktree_loader_test.go Refactor repo_paths.go to use git rev-parse 2024-01-24 08:40:01 +01:00