From: Kristoffer Haugsbakk <code@khaugsbakk.name>
To: git@vger.kernel.org
Cc: Kristoffer Haugsbakk <code@khaugsbakk.name>, peff@peff.net
Subject: [PATCH 0/3] object-name: don't allow @ as a branch name
Date: Mon, 7 Oct 2024 22:15:16 +0200 [thread overview]
Message-ID: <cover.1728331771.git.code@khaugsbakk.name> (raw)
I use `@` a lot for Git commands in the terminal. I accidentally did
something that made me create a branch named `@`. This puzzled me since
`HEAD` is not allowed.
Note that the bare/one-level `@` ref name is already banned. So this is
just about not allowing `refs/heads/@`.
§ Research
This has come up before. There even is a test which guards the current
behavior (allow `@` as a branch name) with the comment:[1]
```
# The thing we are testing here is that "@" is the real branch refs/heads/@,
# and not refs/heads/HEAD. These tests should not imply that refs/heads/@ is a
# sane thing, but it _is_ technically allowed for now. If we disallow it, these
# can be switched to test_must_fail.
```
There was no reply to this change in neither the first[2] nor second
version.
That series points back to a bug report thread[3] which is about
expanding `@` to a branch named `HEAD`.
Peff found a way for the branch name `HEAD` to be created While figuring
out a solution:[4]
> Checking "HEAD" afterwards means you can't actually have a branch
> named "HEAD". Doing so is probably insane, but we probably really _do_
> want to just disallow the @-conversion here.
So that was tangential to the bug fix (`HEAD` as a branch name was not
disallowed in the patch series that resulted from this bug).
🔗 1: https://lore.kernel.org/git/20170302082306.n6kfc5uqz2kdxtpm@sigill.intra.peff.net/
🔗 2: https://public-inbox.org/git/20170228121514.qajydm5bjdbzsucg@sigill.intra.peff.net/
🔗 3: https://public-inbox.org/git/20170228120633.zkwfqms57fk7dkl5@sigill.intra.peff.net/
🔗 4: https://public-inbox.org/git/20170227090233.uk7dfruggytgmuw2@sigill.intra.peff.net/
§2 Disallow `HEAD` as a branch name
This was done later in 2017:
https://lore.kernel.org/git/20171114114259.8937-1-kaartic.sivaraam@gmail.com/
§2 `refs/heads/@` is apparently disallowed by git-refs(1)
See `t/t1508-at-combinations.sh`:
```
error: refs/heads/@: badRefName: invalid refname format
```
Kristoffer Haugsbakk (3):
object-name: fix whitespace
object-name: don't allow @ as a branch name
t1402: exercise disallowed branch names
object-name.c | 5 ++---
t/t1402-check-ref-format.sh | 4 ++++
t/t3204-branch-name-interpretation.sh | 9 ++-------
3 files changed, 8 insertions(+), 10 deletions(-)
--
2.46.1.641.g54e7913fcb6
next reply other threads:[~2024-10-07 20:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-07 20:15 Kristoffer Haugsbakk [this message]
2024-10-07 20:15 ` [PATCH 1/3] object-name: fix whitespace Kristoffer Haugsbakk
2024-10-07 20:15 ` [PATCH 2/3] object-name: don't allow @ as a branch name Kristoffer Haugsbakk
2024-10-07 20:44 ` Jeff King
2024-10-07 20:56 ` Kristoffer Haugsbakk
2024-10-08 6:52 ` Jeff King
2024-10-08 20:37 ` Rubén Justo
2024-10-07 22:01 ` Junio C Hamano
2024-10-08 6:54 ` Jeff King
2024-10-07 20:15 ` [PATCH 3/3] t1402: exercise disallowed branch names Kristoffer Haugsbakk
2024-10-07 20:47 ` Jeff King
2024-10-07 20:37 ` [PATCH 0/3] object-name: don't allow @ as a branch name Jeff King
2024-10-07 20:40 ` Kristoffer Haugsbakk
2024-10-08 13:19 ` shejialuo
2024-10-08 14:19 ` Kristoffer Haugsbakk
2024-10-18 14:21 ` shejialuo
2024-10-08 18:17 ` Junio C Hamano
2024-10-09 12:00 ` shejialuo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1728331771.git.code@khaugsbakk.name \
--to=code@khaugsbakk.name \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.