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

Re: [PATCH 2/3] object-name: don't allow @ as a branch name

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 7, 2024, 22:01 UTC
Message-ID
<xmqqy12z7eti.fsf@gitster.g>
In-Reply-To
<b88c2430f88b641d69e5f161d3a18cce113a81c9.1728331771.git.code@khaugsbakk.name>
Kristoffer Haugsbakk <code@khaugsbakk.name> writes:
Show 6 quoted lines
> `HEAD` is an invalid branch name.[1]  But the `@` synonym is allowed.
> This is just as inconvenient since commands like `git checkout @` will,
> quite sensibly, do `git checkout HEAD` instead of checking out that
> branch; in turn there is no practical reason to use this as a branch
> name since you cannot even check out the branch itself (only check out
> the commit which `refs/heads/@` points to).
I am not sure this is sensible at all, after all these years.

I suspect that it is much more productive to deprecate and remove "@" that is a built-in synomym for HEAD (but "refs/remotes/origin/@" does not act as a synonym for "refs/remotes/origin/HEAD"). Having two ways to call the same thing merely adds to confusion in this case, unlike "HEAD" referring to 'master' (when 'master' is checked out), which is also to have two ways to call the same thing, but adds a true convenience.

Those who really want to use @ can do something like
	$ echo "ref: HEAD" >.git/@
or something, perhaps.
Previous: Rubén JustoNext: Jeff King
Message 8 of 18 in “object-name: don't allow @ as a branch name”
  1. 0/3 object-name: don't allow @ as a branch nameKristoffer Haugsbakk, Oct 7, 2024
  2. 1/3 object-name: fix whitespaceKristoffer Haugsbakk, Oct 7, 2024
  3. 2/3 object-name: don't allow @ as a branch nameKristoffer Haugsbakk, Oct 7, 2024
  4. Jeff KingOct 7, 2024
  5. Kristoffer HaugsbakkOct 7, 2024
  6. Jeff KingOct 8, 2024
  7. Rubén JustoOct 8, 2024
  8. Junio C HamanoOct 7, 2024
  9. Jeff KingOct 8, 2024
  10. 3/3 t1402: exercise disallowed branch namesKristoffer Haugsbakk, Oct 7, 2024
  11. Jeff KingOct 7, 2024
  12. Jeff KingOct 7, 2024
  13. Kristoffer HaugsbakkOct 7, 2024
  14. shejialuoOct 8, 2024
  15. Kristoffer HaugsbakkOct 8, 2024
  16. shejialuoOct 18, 2024
  17. Junio C HamanoOct 8, 2024
  18. shejialuoOct 9, 2024

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.