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>
This commit is contained in:

committed by
Junio C Hamano

parent
15cb03728f
commit
8fbd903e58
8
branch.c
8
branch.c
@ -370,8 +370,12 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
|
||||
*/
|
||||
int validate_branchname(const char *name, struct strbuf *ref)
|
||||
{
|
||||
if (strbuf_check_branch_ref(ref, name))
|
||||
die(_("'%s' is not a valid branch name"), name);
|
||||
if (strbuf_check_branch_ref(ref, name)) {
|
||||
int code = die_message(_("'%s' is not a valid branch name"), name);
|
||||
advise_if_enabled(ADVICE_REF_SYNTAX,
|
||||
_("See `man git check-ref-format`"));
|
||||
exit(code);
|
||||
}
|
||||
|
||||
return ref_exists(ref->buf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user