{"thread":{"id":"24159","subject":"[PATCH] checkout: Better error message on invalid branch name","startedAt":"2010-06-21T18:53:39Z","lastAt":"2010-06-21T21:09:11Z","messageCount":3,"participants":["Ævar Arnfjörð Bjarmason","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"143994","messageId":"1277146419-19507-1-git-send-email-avarab@gmail.com","threadId":"24159","inReplyTo":null,"subject":"[PATCH] checkout: Better error message on invalid branch name","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-06-21T18:53:39Z","receivedAt":"2010-06-21T18:53:39Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the error message for `git checkout -b \"I LOVE YOU\"' and other\ninvalid branch names to say what branch names are invalid, rather than\njust saying we don't like it.\n\nBefore:\n\n    $ git checkout -b \"I LOVE YOU\"\n    fatal: git checkout: we do not like 'I LOVE YOU' as a branch name.\n\nAfter:\n\n    $ git checkout -b \"I LOVE YOU\"\n    fatal: git checkout: The name \"I LOVE YOU\" is not a valid Git branch name.\n    A branch name can not:\n        - Have a path component that begins with \".\"\n        - Have a double dot \"..\"\n        - Have an ASCII control character, \"~\", \"^\", \":\" or SP, anywhere\n        - End with a \"/\"\n        - End with \".lock\"\n        - Contain a \"\\\" (backslash\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n\nGit didn't like my branch name, but I didn't like its error\nmessage. Here's a fix for it.\n\n builtin/checkout.c |   10 +++++++++-\n 1 files changed, 9 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 1994be9..fec8335 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -856,7 +856,15 @@ no_reference:\n \tif (opts.new_branch) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tif (strbuf_check_branch_ref(&buf, opts.new_branch))\n-\t\t\tdie(\"git checkout: we do not like '%s' as a branch name.\",\n+\t\t\tdie(\"git checkout: The name \\\"%s\\\" is not a valid branch name.\\n\"\n+\t\t\t    \"A branch name can not:\\n\"\n+\t\t\t    /* From the comment for bad_ref_char in refs.c */\n+\t\t\t    \"    - Have a path component that begins with \\\".\\\"\\n\"\n+\t\t\t    \"    - Have a double dot \\\"..\\\"\\n\"\n+\t\t\t    \"    - Have an ASCII control character, \\\"~\\\", \\\"^\\\", \\\":\\\" or SP, anywhere\\n\"\n+\t\t\t    \"    - End with a \\\"/\\\"\\n\"\n+\t\t\t    \"    - End with \\\".lock\\\"\\n\"\n+\t\t\t    \"    - Contain a \\\"\\\\\\\" (backslash)\",\n \t\t\t    opts.new_branch);\n \t\tif (!get_sha1(buf.buf, rev))\n \t\t\tdie(\"git checkout: branch %s already exists\", opts.new_branch);\n-- \n1.7.1.251.g92a7\n"},{"id":"143997","messageId":"7vd3vkgl0y.fsf@alter.siamese.dyndns.org","threadId":"24159","inReplyTo":"1277146419-19507-1-git-send-email-avarab@gmail.com","subject":"Re: [PATCH] checkout: Better error message on invalid branch name","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-21T20:58:53Z","receivedAt":"2010-06-21T20:58:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Change the error message for `git checkout -b \"I LOVE YOU\"' and other\n> invalid branch names to say what branch names are invalid, rather than\n> just saying we don't like it.\n>\n> Before:\n>\n>     $ git checkout -b \"I LOVE YOU\"\n>     fatal: git checkout: we do not like 'I LOVE YOU' as a branch name.\n>\n> After:\n>\n>     $ git checkout -b \"I LOVE YOU\"\n>     fatal: git checkout: The name \"I LOVE YOU\" is not a valid Git branch name.\n>     A branch name can not:\n>         - Have a path component that begins with \".\"\n>         - Have a double dot \"..\"\n>         - Have an ASCII control character, \"~\", \"^\", \":\" or SP, anywhere\n>         - End with a \"/\"\n>         - End with \".lock\"\n>         - Contain a \"\\\" (backslash\n\nCluttering the output without protecting it with \"advice\" does not look\nlike a \"fix\" nor improvement.\n"},{"id":"143998","messageId":"AANLkTino4Dz_nMSV_4HHKD3K185t7spE22d5chLdo960@mail.gmail.com","threadId":"24159","inReplyTo":"7vd3vkgl0y.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] checkout: Better error message on invalid branch name","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-06-21T21:09:11Z","receivedAt":"2010-06-21T21:09:11Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, Jun 21, 2010 at 20:58, Junio C Hamano <gitster@pobox.com> wrote:\n> Cluttering the output without protecting it with \"advice\" does not look\n> like a \"fix\" nor improvement.\n\nThe short version of the message would also need to be fixed then, to\ndo that properly would require bigger changes in the return code of\nbad_ref_char and the functions that call it. Then we could have e.g.:\n\n    $ git checkout -b \"I LOVE YOU\"\n    fatal: git checkout: Branch name cannot contain ' ';  marked by\n<-- HERE in 'I ' <-- HERE\n\nSimilar to what you get from:\n\n    $ perl -e '/I LOVE [/'\n\nThat would also make the long version unnecessary, and maybe improve\nsome other error messages that deal with ref names.\n"}]}