{"thread":{"id":"7356","subject":"git-check-ref-format returns 1 for valid branch names","startedAt":"2007-03-22T20:24:59Z","lastAt":"2007-03-22T21:58:07Z","messageCount":5,"participants":["Nikolai Weibull","Junio C Hamano","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"37755","messageId":"dbfc82860703221324k48690833g6731ef75562839d6@mail.gmail.com","threadId":"7356","inReplyTo":null,"subject":"git-check-ref-format returns 1 for valid branch names","fromName":"Nikolai Weibull","fromEmail":"now@bitwi.se","sentAt":"2007-03-22T20:24:59Z","receivedAt":"2007-03-22T20:24:59Z","isPatch":false,"sender":{"key":"now@bitwi.se","avatar":"https://gravatar.com/avatar/d9242f067845cf9a72be23e4213c3b6e53492178e5df97372088a441af846133?d=mp&s=160"},"body":"I'm obviously doing something wrong, but in git 1.5.0.4\n\n% git check-ref-format abc\n% echo $?\n1\n\nWhat am I missing here?\n\n  nikolai\n"},{"id":"37757","messageId":"7vejnht3x2.fsf@assigned-by-dhcp.cox.net","threadId":"7356","inReplyTo":"dbfc82860703221324k48690833g6731ef75562839d6@mail.gmail.com","subject":"Re: git-check-ref-format returns 1 for valid branch names","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-22T20:32:41Z","receivedAt":"2007-03-22T20:32:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Nikolai Weibull\" <now@bitwi.se> writes:\n\n> I'm obviously doing something wrong, but in git 1.5.0.4\n>\n> % git check-ref-format abc\n> % echo $?\n> 1\n>\n> What am I missing here?\n\nIf you are trying to see if abc is a valid branch name, try refs/heads/abc.\n"},{"id":"37758","messageId":"dbfc82860703221342h4e1ade1am2961a0a996d7d20c@mail.gmail.com","threadId":"7356","inReplyTo":"7vejnht3x2.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-check-ref-format returns 1 for valid branch names","fromName":"Nikolai Weibull","fromEmail":"now@bitwi.se","sentAt":"2007-03-22T20:42:59Z","receivedAt":"2007-03-22T20:42:59Z","isPatch":false,"sender":{"key":"now@bitwi.se","avatar":"https://gravatar.com/avatar/d9242f067845cf9a72be23e4213c3b6e53492178e5df97372088a441af846133?d=mp&s=160"},"body":"On 3/22/07, Junio C Hamano <junkio@cox.net> wrote:\n> \"Nikolai Weibull\" <now@bitwi.se> writes:\n>\n> > I'm obviously doing something wrong, but in git 1.5.0.4\n> >\n> > % git check-ref-format abc\n> > % echo $?\n> > 1\n> >\n> > What am I missing here?\n>\n> If you are trying to see if abc is a valid branch name, try refs/heads/abc.\n\nThanks.  I just saw an example in git-checkout (where it's testing\n\"heads/$newbranch\").\n\n  nikolai\n"},{"id":"37760","messageId":"Pine.LNX.4.64.0703221358420.6730@woody.linux-foundation.org","threadId":"7356","inReplyTo":"7vejnht3x2.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-check-ref-format returns 1 for valid branch names","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-03-22T21:03:41Z","receivedAt":"2007-03-22T21:03:41Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 22 Mar 2007, Junio C Hamano wrote:\n\n> \"Nikolai Weibull\" <now@bitwi.se> writes:\n> \n> > I'm obviously doing something wrong, but in git 1.5.0.4\n> >\n> > % git check-ref-format abc\n> > % echo $?\n> > 1\n> >\n> > What am I missing here?\n> \n> If you are trying to see if abc is a valid branch name, try refs/heads/abc.\n\n.. and before anybody wonders why it wants the \"fully qualified\" name, \nit's because \"abc\" on its own is ambiguous. Is it a _tag_ called \"abc\", or \na branch, or what? That explains why - if you really want to verify a \nref-name, you need to give the full name..\n\nOn the other hand, if you don't care, and you just want \"is this a valid \ncommit name\", use\n\n\tsha1=$(git rev-parse --verify \"$name\"^0) || exit\n\nor similar. It won't care if \"name\" is ambiguous or not, it will just try \nto parse it as a revision expression (with the \"^0\" there to force a tag \nto be converted to a commit-name, or force an error if the SHA1 is not a \nvalid commit).\n\n\t\t\tLinus\n"},{"id":"37763","messageId":"dbfc82860703221458j690d1cafve01174eda8f149ee@mail.gmail.com","threadId":"7356","inReplyTo":"Pine.LNX.4.64.0703221358420.6730@woody.linux-foundation.org","subject":"Re: git-check-ref-format returns 1 for valid branch names","fromName":"Nikolai Weibull","fromEmail":"now@bitwi.se","sentAt":"2007-03-22T21:58:07Z","receivedAt":"2007-03-22T21:58:07Z","isPatch":false,"sender":{"key":"now@bitwi.se","avatar":"https://gravatar.com/avatar/d9242f067845cf9a72be23e4213c3b6e53492178e5df97372088a441af846133?d=mp&s=160"},"body":"On 3/22/07, Linus Torvalds <torvalds@linux-foundation.org> wrote:\n>\n>\n> On Thu, 22 Mar 2007, Junio C Hamano wrote:\n>\n> > \"Nikolai Weibull\" <now@bitwi.se> writes:\n> >\n> > > I'm obviously doing something wrong, but in git 1.5.0.4\n> > >\n> > > % git check-ref-format abc\n> > > % echo $?\n> > > 1\n> > >\n> > > What am I missing here?\n> >\n> > If you are trying to see if abc is a valid branch name, try refs/heads/abc.\n>\n> .. and before anybody wonders why it wants the \"fully qualified\" name,\n> it's because \"abc\" on its own is ambiguous. Is it a _tag_ called \"abc\", or\n> a branch, or what? That explains why - if you really want to verify a\n> ref-name, you need to give the full name..\n>\n> On the other hand, if you don't care, and you just want \"is this a valid\n> commit name\", use\n>\n>         sha1=$(git rev-parse --verify \"$name\"^0) || exit\n\nThanks for the clarification.\n\nWhat I was after was a way to verify that a name is a valid new name\nof a branch, for the Zsh completion definition in the context of\ngit-checkout -b <new_branch>. [1]  After posting I realized that\nperhaps checking out the sources for git-checkout would enlighten me,\nwhich it did, as it uses git-check-ref-format \"heads/$newbranch\" to\nverify that the new branch's name  is valid.\n\n[1] It's not really going to try to complete anything here, but verify\nthat the new branch's name is valid while the user types it in. [2]\n[2]  Hm, perhaps completing existing branch-names makes more sense,\nallowing the user to create a new branch-name based on an old one.\n"}]}