Re: [PATCH v3 1/2] rebase: skip branch symref aliases
Phillip Wood <[email protected]> Wed, 29 Jul 2026 10:31:34 +0100
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <[email protected]> |
On 28/07/2026 15:23, Junio C Hamano wrote: > Phillip Wood <[email protected]> writes: > >>> But stepping back a bit, is having a HEAD that is a symref and >>> points outside "refs/heads/" an invalid state? Why are we catering >>> to such a configuration to begin with? >> >> We allow HEAD to point to anything below "refs/" - see e9cc02f0e4 >> (symbolic-ref: allow refs/<whatever> in HEAD, 2009-02-13). > > But that was about a low level mechanism that must be more lenient > to be usable as repair tools to recover from such a broken state, > no? It checks the new value of HEAD, not the old one so I don't think so. The commit message talks about topgit using "git symbolic-ref" to set head outside "refs/heads/" - peff had previously tried to tighten it to reject non-branch refs but that broke topgit. I've just had a quick look at the topgit code and still sets HEAD to point to "refs/top-bases/..." by default[1], although there are plans to start using "refs/heads/{top-bases}/..." instead. > I thought the end-user facing commands like "git checkout" have > been tightened long ago to stop users from getting into a situation > that needs repairing in the first place. And that was why I asked. Yes "git checkout" detaches HEAD if you give a non-branch ref, but external tools can still use "git symbolic-ref" to bypass that. It appears topgit's rebase command is built around "git rebase"[2] so I think we need to continue to support rebasing a non-branch HEAD. Thanks Phillip [1] https://github.com/mackyle/topgit/blob/master/tg.sh#L2683 [2] https://github.com/mackyle/topgit/blob/master/tg-rebase.sh#L56