git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Nikolai Weibull <now@bitwi.se>, git <git@vger.kernel.org>
Subject: Re: git-check-ref-format returns 1 for valid branch names
Date: Thu, 22 Mar 2007 14:03:41 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0703221358420.6730@woody.linux-foundation.org> (raw)
In-Reply-To: <7vejnht3x2.fsf@assigned-by-dhcp.cox.net>



On Thu, 22 Mar 2007, Junio C Hamano wrote:

> "Nikolai Weibull" <now@bitwi.se> writes:
> 
> > I'm obviously doing something wrong, but in git 1.5.0.4
> >
> > % git check-ref-format abc
> > % echo $?
> > 1
> >
> > What am I missing here?
> 
> If you are trying to see if abc is a valid branch name, try refs/heads/abc.

.. and before anybody wonders why it wants the "fully qualified" name, 
it's because "abc" on its own is ambiguous. Is it a _tag_ called "abc", or 
a branch, or what? That explains why - if you really want to verify a 
ref-name, you need to give the full name..

On the other hand, if you don't care, and you just want "is this a valid 
commit name", use

	sha1=$(git rev-parse --verify "$name"^0) || exit

or similar. It won't care if "name" is ambiguous or not, it will just try 
to parse it as a revision expression (with the "^0" there to force a tag 
to be converted to a commit-name, or force an error if the SHA1 is not a 
valid commit).

			Linus

  parent reply	other threads:[~2007-03-22 21:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-22 20:24 git-check-ref-format returns 1 for valid branch names Nikolai Weibull
2007-03-22 20:32 ` Junio C Hamano
2007-03-22 20:42   ` Nikolai Weibull
2007-03-22 21:03   ` Linus Torvalds [this message]
2007-03-22 21:58     ` Nikolai Weibull

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=Pine.LNX.4.64.0703221358420.6730@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=now@bitwi.se \
    /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).