diff options
author | Derrick Stolee <derrickstolee@github.com> | 2022-07-19 20:33:41 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-07-19 21:49:04 +0200 |
commit | b3b1a21d1a5df87e81fa8b53c6c3cf9760ca12d4 (patch) | |
tree | b5e346ed2f5f55e5006372505ff9950272bd03d5 /rebase-interactive.c | |
parent | rebase: update refs from 'update-ref' commands (diff) | |
download | git-b3b1a21d1a5df87e81fa8b53c6c3cf9760ca12d4.tar.xz git-b3b1a21d1a5df87e81fa8b53c6c3cf9760ca12d4.zip |
sequencer: rewrite update-refs as user edits todo list
An interactive rebase provides opportunities for the user to edit the
todo list. The --update-refs option initializes the list with some
'update-ref <ref>' steps, but the user could add these manually.
Further, the user could add or remove these steps during pauses in the
interactive rebase.
Add a new method, todo_list_filter_update_refs(), that scans a todo_list
and compares it to the stored update-refs file. There are two actions
that can happen at this point:
1. If a '<ref>/<before>/<after>' triple in the update-refs file does not
have a matching 'update-ref <ref>' command in the todo-list _and_ the
<after> value is the null OID, then remove that triple. Here, the
user removed the 'update-ref <ref>' command before it was executed,
since if it was executed then the <after> value would store the
commit at that position.
2. If a 'update-ref <ref>' command in the todo-list does not have a
matching '<ref>/<before>/<after>' triple in the update-refs file,
then insert a new one. Store the <before> value to be the current
OID pointed at by <ref>. This is handled inside of the
init_update_ref_record() helper method.
We can test that this works by rewriting the todo-list several times in
the course of a rebase. Check that each ref is locked or unlocked for
updates after each todo-list update. We can also verify that the ref
update fails if a concurrent process updates one of the refs after the
rebase process records the "locked" ref location.
To help these tests, add a new 'set_replace_editor' helper that will
replace the todo-list with an exact file.
Reported-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'rebase-interactive.c')
-rw-r--r-- | rebase-interactive.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/rebase-interactive.c b/rebase-interactive.c index 1ff07647af..7407c59319 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -146,6 +146,12 @@ int edit_todo_list(struct repository *r, struct todo_list *todo_list, return -4; } + /* + * See if branches need to be added or removed from the update-refs + * file based on the new todo list. + */ + todo_list_filter_update_refs(r, new_todo); + return 0; } |