git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 1/2] rebase: skip branch symref aliases

From
ECErik Cervin-Edin <erik@cervined.in>
Date
Jul 25, 2026, 11:21 UTC
Message-ID
<amSSYagL0jTgzElD@mbp>
In-Reply-To
<00e529b6-7ae7-463f-a4b3-0991e9411aba@gmail.com>

I ran into a minor regression that I tracked down to v2 of this patch series. When I was running

    git rebase --interactive --update-refs

I got a comment in my git-rebase-todo for the branch I was rebasing, even though it's just the current branch in the current worktree:

    # Ref refs/heads/main checked out at '/private/tmp/gittest'

where I'd expect no entry at all, since the branch is updated by the rebase itself. After applying v3 of the series, the regression went away. Nevertheless, I thought I ought to share what I found.

On 26/07/24 10:55AM, Phillip Wood wrote:
Show 10 quoted lines
> > > +        if (head_ref && !strcmp(head_ref, decoration->name)) {
> > > +            free(resolved_ref);
> > >               decoration = decoration->next;
> > >               continue;
> > >           }
> > > +
> > > +        path = branch_checked_out(decoration->name);
> >
> > Then we check to see if the decoration matches HEAD which we used to do
> > above - I'm not clear why we have moved this check.

branch_checked_out() can't tell "checked out in another worktree" apart from "checked out right here", so `path` is never NULL for the branch actually being rebased. In v2, the check above was instead:

    if (!path && head_ref && !strcmp(head_ref, decoration->name))
        continue;

which made it a no-op for exactly that branch -- the regression I observed. v3 drops the `!path` gate and moves `path` below it, which is why it's fixed.

> > As topic2 is checked out in the worktree where the rebase is running
> > why did this line appear before?

This might be the same symptom from another cause: on master, head_ref comes from refs_resolve_ref_unsafe(), and as you note its buffer is overwritten inside branch_checked_out(). So by the time topic2 is compared, wt-topic's lookup may already have clobbered head_ref, letting topic2 fall through to the comment. I haven't run the test to confirm, though.

Thanks, Erik

Previous: Phillip WoodNext: Junio C Hamano
Message 15 of 25 in “rebase: handle --update-refs branch symrefs”
  1. 0/2 rebase: handle --update-refs branch symrefsSon Luong Ngoc via GitGitGadget, May 28, 2026
  2. 1/2 t3404: add failing branch symref testSon Luong Ngoc via GitGitGadget, May 28, 2026
  3. Phillip WoodJun 1, 2026
  4. 2/2 rebase: skip branch symref aliasesSon Luong Ngoc via GitGitGadget, May 28, 2026
  5. Kristoffer HaugsbakkMay 28, 2026
  6. Phillip WoodJun 1, 2026
  7. Junio C HamanoMay 28, 2026
  8. rebase: skip branch symref aliasesSon Luong Ngoc via GitGitGadget, Jun 3, 2026
  9. Phillip WoodJun 4, 2026
  10. Son Luong NgocJul 22, 2026
  11. 0/2 rebase: handle --update-refs branch symrefsSon Luong Ngoc via GitGitGadget, Jul 22, 2026
  12. 1/2 rebase: skip branch symref aliasesSon Luong Ngoc via GitGitGadget, Jul 22, 2026
  13. Phillip WoodJul 23, 2026
  14. Phillip WoodJul 24, 2026
  15. Erik Cervin-EdinJul 25, 2026
  16. Junio C HamanoJul 26, 2026
  17. Phillip WoodJul 28, 2026
  18. Junio C HamanoJul 28, 2026
  19. Phillip WoodJul 29, 2026
  20. Junio C HamanoJul 29, 2026
  21. Phillip WoodJul 30, 2026
  22. Junio C HamanoAug 6, 2026
  23. Phillip WoodAug 7, 2026
  24. 2/2 rebase: guard non-branch symref targetsSon Luong Ngoc via GitGitGadget, Jul 22, 2026
  25. Phillip WoodAug 7, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.