add_decorations_to_list() skips the branch HEAD points to, because the rebase updates it anyway, per aa37f3e1d89. Andy Koppe says it keeps that branch's name in the static buffer returned by refs_resolve_ref_unsafe().
If another branch on the same commit is checked out in a different worktree, branch_checked_out() overwrites that buffer. Depending on the order of decorations, the current branch gets a "checked out" comment in the todo list instead of being skipped, and the branch whose name ended up in the buffer is skipped in its place. Decorations are processed in reverse alphabetical order. The patch fixes the name handling so the lookup no longer clobbers it.
Junio C Hamano said the original was obviously broken and the correction is clean. He said he likes it and will queue it.