Re: git-check-ref-format returns 1 for valid branch names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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

> "Nikolai Weibull" <now@xxxxxxxx> 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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]