diff options
author | Kristoffer Haugsbakk <code@khaugsbakk.name> | 2024-03-05 21:29:43 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-03-05 13:04:26 -0800 |
commit | 8fbd903e58503cbdd1f1c816dd0c6c3c4d591b13 (patch) | |
tree | bdcac7428df8f52598ee55307389ff0cc6dfcee8 /builtin | |
parent | 15cb03728f2fa6f153f873307ec92bb187681766 (diff) | |
download | git-8fbd903e58503cbdd1f1c816dd0c6c3c4d591b13.tar.gz |
branch: advise about ref syntax rules
git-branch(1) will error out if you give it a bad ref name. But the user
might not understand why or what part of the name is illegal.
The user might know that there are some limitations based on the *loose
ref* format (filenames), but there are also further rules for
easier integration with shell-based tools, pathname expansion, and
playing well with reference name expressions.
The man page for git-check-ref-format(1) contains these rules. Let’s
advise about it since that is not a command that you just happen
upon. Also make this advise configurable since you might not want to be
reminded every time you make a little typo.
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/branch.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin/branch.c b/builtin/branch.c index cfb63cce5f..1c122ee8a7 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -576,8 +576,12 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int */ if (ref_exists(oldref.buf)) recovery = 1; - else - die(_("invalid branch name: '%s'"), oldname); + else { + int code = die_message(_("invalid branch name: '%s'"), oldname); + advise_if_enabled(ADVICE_REF_SYNTAX, + _("See `man git check-ref-format`")); + exit(code); + } } for (int i = 0; worktrees[i]; i++) { |