Merge branch 'ak/sequencer-head-refdup'

The branch decoration logic in the sequencer has been updated to use
an allocated buffer for the HEAD reference name, preventing it from
being clobbered when evaluating branches checked out in other
worktrees.

* ak/sequencer-head-refdup:
  sequencer: don't clobber HEAD ref name in worktree lookup
This commit is contained in:
Junio C Hamano committed 2026-10-26 07:28:00 -07:00
commit bd52c76874
2 files changed
+22 -2

No files matched your search

+2 -1
View File
@@ -6618,7 +6618,7 @@ static int add_decorations_to_list(const struct commit *commit,
struct todo_add_branch_context *ctx)
{
const struct name_decoration *decoration = get_name_decoration(&commit->object);
const char *head_ref = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
char *head_ref = refs_resolve_refdup(get_main_ref_store(the_repository),
"HEAD",
RESOLVE_REF_READING,
NULL,
@@ -6674,6 +6674,7 @@ static int add_decorations_to_list(const struct commit *commit,
decoration = decoration->next;
}
free(head_ref);
return 0;
}
+20 -1
View File
@@ -483,7 +483,26 @@ test_expect_success 'git rebase --update-ref with core.commentChar and branch on
GIT_SEQUENCE_EDITOR="cat >actual" git -c core.commentChar=% \
rebase -i --update-refs base &&
test_grep "% Ref refs/heads/wt-topic checked out at" actual &&
test_grep "% Ref refs/heads/topic2 checked out at" actual
test_grep ! "Ref refs/heads/topic2" actual
'
test_expect_success 'git rebase --update-refs ignores current branch with branches on worktrees' '
test_when_finished git branch -D base current a-topic z-topic &&
test_when_finished git checkout main &&
test_when_finished git worktree remove z-topic &&
test_when_finished git worktree remove a-topic &&
git checkout -b base main &&
git checkout -b current &&
test_commit msg4 &&
git worktree add a-topic &&
git worktree add z-topic &&
git checkout base &&
test_commit msg5 &&
git checkout current &&
GIT_SEQUENCE_EDITOR="cat >actual" git rebase -i --update-refs base &&
test_grep "# Ref refs/heads/a-topic checked out at" actual &&
test_grep "# Ref refs/heads/z-topic checked out at" actual &&
test_grep ! "refs/heads/current" actual
'
test_done