Skip to content

Commit aa37f3e

Browse files
derrickstoleegitster
authored andcommitted
sequencer: ignore HEAD ref under --update-refs
When using the 'git rebase -i --update-refs' option, the todo list is populated with 'update-ref' commands for all tip refs in the history that is being rebased. Refs that are checked out by some worktree are instead added as a comment to warn the user that they will not be updated. Until now, this included the HEAD ref, which is being updated by the rebase process itself, regardless of the --update-refs option. Remove the comment in this case by ignoring any decorations that match the HEAD ref. Reported-by: Elijah Newren <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3113fed commit aa37f3e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sequencer.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5888,12 +5888,25 @@ static int add_decorations_to_list(const struct commit *commit,
58885888
struct todo_add_branch_context *ctx)
58895889
{
58905890
const struct name_decoration *decoration = get_name_decoration(&commit->object);
5891+
const char *head_ref = resolve_ref_unsafe("HEAD",
5892+
RESOLVE_REF_READING,
5893+
NULL,
5894+
NULL);
58915895

58925896
while (decoration) {
58935897
struct todo_item *item;
58945898
const char *path;
58955899
size_t base_offset = ctx->buf->len;
58965900

5901+
/*
5902+
* If the branch is the current HEAD, then it will be
5903+
* updated by the default rebase behavior.
5904+
*/
5905+
if (head_ref && !strcmp(head_ref, decoration->name)) {
5906+
decoration = decoration->next;
5907+
continue;
5908+
}
5909+
58975910
ALLOC_GROW(ctx->items,
58985911
ctx->items_nr + 1,
58995912
ctx->items_alloc);

0 commit comments

Comments
 (0)