From: Kristoffer Haugsbakk <code@khaugsbakk.name>
To: git@vger.kernel.org
Cc: Kristoffer Haugsbakk <code@khaugsbakk.name>
Subject: [PATCH v2 0/1] advise about ref syntax rules
Date: Sun, 3 Mar 2024 19:58:20 +0100 [thread overview]
Message-ID: <cover.1709491818.git.code@khaugsbakk.name> (raw)
In-Reply-To: <d275d1d179b90592ddd7b5da2ae4573b3f7a37b7.1709307442.git.code@khaugsbakk.name>
Point the user towards the ref/branch name syntax rules if they give an
invalid name.
§ git-replace(1)
I did not add a hint for a similar message in `builtin/replace.c`.
`builtin/replace.c` has an error message in `check_ref_valid` for an
invalid ref name:
```
return error(_("'%s' is not a valid ref name"), ref->buf);
```
But there doesn’t seem to be a point to placing a hint here.
The preceding calls to `repo_get_oid` will catch both missing refs and
existing refs with invalid names:
```
if (repo_get_oid(r, refname, &object))
return error(_("failed to resolve '%s' as a valid ref"), refname);
```
Like for example this:
```
$ printf $(git rev-parse @~) > .git/refs/heads/hello..goodbye
$ git replace @ hello..goodbye
error: failed to resolve 'hello..goodbye' as a valid ref
[…]
$ git replace @ non-existing
error: failed to resolve 'non-existing' as a valid ref
```
§ Alternatives (to this change)
While working on this I also thought that it might be nice to have a
man page `gitrefsyntax`. That one could use a lot of the content from
`man git check-ref-format` verbatim. Then the hint could point towards
that man page. And it seems that AsciiDoc supports _includes_ which
means that the rules don’t have to be duplicated between the two man
pages.
§ Changes in v2
• Make the advise optional via configuration
• At first I thought that this wasn’t needed but I imagine the advice
could get repetitive for typos and such
• Propagate error properly with `die_message(…)` instead of `exit(1)`
• Flesh out commit message a bit
Kristoffer Haugsbakk (1):
branch: advise about ref syntax rules
Documentation/config/advice.txt | 3 +++
advice.c | 1 +
advice.h | 1 +
branch.c | 8 ++++++--
builtin/branch.c | 8 ++++++--
t/t3200-branch.sh | 11 +++++++++++
6 files changed, 28 insertions(+), 4 deletions(-)
--
2.44.0.64.g52b67adbeb2
next prev parent reply other threads:[~2024-03-03 18:59 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 15:38 [PATCH] branch: advise about ref syntax rules Kristoffer Haugsbakk
2024-03-01 18:06 ` Junio C Hamano
2024-03-01 18:13 ` Kristoffer Haugsbakk
2024-03-01 18:32 ` Junio C Hamano
2024-03-03 18:58 ` Kristoffer Haugsbakk [this message]
2024-03-03 18:58 ` [PATCH v2 1/1] " Kristoffer Haugsbakk
2024-03-03 22:42 ` Junio C Hamano
2024-03-03 22:58 ` Kristoffer Haugsbakk
2024-03-04 22:07 ` [PATCH v3 0/5] " Kristoffer Haugsbakk
2024-03-04 22:07 ` [PATCH v3 1/5] t3200: improve test style Kristoffer Haugsbakk
2024-03-05 1:25 ` Junio C Hamano
2024-03-05 10:27 ` Kristoffer Haugsbakk
2024-03-05 16:02 ` Junio C Hamano
2024-03-04 22:07 ` [PATCH v3 2/5] advice: make all entries stylistically consistent Kristoffer Haugsbakk
2024-03-04 23:52 ` Junio C Hamano
2024-03-05 10:36 ` Kristoffer Haugsbakk
2024-03-04 22:07 ` [PATCH v3 3/5] advice: use backticks for code Kristoffer Haugsbakk
2024-03-04 23:54 ` Junio C Hamano
2024-03-05 10:29 ` Kristoffer Haugsbakk
2024-03-04 22:07 ` [PATCH v3 4/5] advice: use double quotes for regular quoting Kristoffer Haugsbakk
2024-03-04 22:07 ` [PATCH v3 5/5] branch: advise about ref syntax rules Kristoffer Haugsbakk
2024-03-05 20:29 ` [PATCH v4 0/5] " Kristoffer Haugsbakk
2024-03-05 20:29 ` [PATCH v4 1/5] t3200: improve test style Kristoffer Haugsbakk
2024-03-05 20:29 ` [PATCH v4 2/5] advice: make all entries stylistically consistent Kristoffer Haugsbakk
2024-03-05 20:29 ` [PATCH v4 3/5] advice: use backticks for verbatim Kristoffer Haugsbakk
2024-03-05 20:29 ` [PATCH v4 4/5] advice: use double quotes for regular quoting Kristoffer Haugsbakk
2024-03-05 20:29 ` [PATCH v4 5/5] branch: advise about ref syntax rules Kristoffer Haugsbakk
2024-03-03 19:10 ` [PATCH v2 0/1] " Kristoffer Haugsbakk
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.1709491818.git.code@khaugsbakk.name \
--to=code@khaugsbakk.name \
--cc=git@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).