git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git-check-ref-format returns 1 for valid branch names
@ 2007-03-22 20:24 Nikolai Weibull
  2007-03-22 20:32 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Nikolai Weibull @ 2007-03-22 20:24 UTC (permalink / raw
  To: git

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?

  nikolai

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-check-ref-format returns 1 for valid branch names
  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
  0 siblings, 2 replies; 5+ messages in thread
From: Junio C Hamano @ 2007-03-22 20:32 UTC (permalink / raw
  To: Nikolai Weibull; +Cc: git

"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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-check-ref-format returns 1 for valid branch names
  2007-03-22 20:32 ` Junio C Hamano
@ 2007-03-22 20:42   ` Nikolai Weibull
  2007-03-22 21:03   ` Linus Torvalds
  1 sibling, 0 replies; 5+ messages in thread
From: Nikolai Weibull @ 2007-03-22 20:42 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git

On 3/22/07, Junio C Hamano <junkio@cox.net> 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.

Thanks.  I just saw an example in git-checkout (where it's testing
"heads/$newbranch").

  nikolai

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-check-ref-format returns 1 for valid branch names
  2007-03-22 20:32 ` Junio C Hamano
  2007-03-22 20:42   ` Nikolai Weibull
@ 2007-03-22 21:03   ` Linus Torvalds
  2007-03-22 21:58     ` Nikolai Weibull
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2007-03-22 21:03 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Nikolai Weibull, git



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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-check-ref-format returns 1 for valid branch names
  2007-03-22 21:03   ` Linus Torvalds
@ 2007-03-22 21:58     ` Nikolai Weibull
  0 siblings, 0 replies; 5+ messages in thread
From: Nikolai Weibull @ 2007-03-22 21:58 UTC (permalink / raw
  To: Linus Torvalds; +Cc: Junio C Hamano, git

On 3/22/07, Linus Torvalds <torvalds@linux-foundation.org> wrote:
>
>
> 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

Thanks for the clarification.

What I was after was a way to verify that a name is a valid new name
of a branch, for the Zsh completion definition in the context of
git-checkout -b <new_branch>. [1]  After posting I realized that
perhaps checking out the sources for git-checkout would enlighten me,
which it did, as it uses git-check-ref-format "heads/$newbranch" to
verify that the new branch's name  is valid.

[1] It's not really going to try to complete anything here, but verify
that the new branch's name is valid while the user types it in. [2]
[2]  Hm, perhaps completing existing branch-names makes more sense,
allowing the user to create a new branch-name based on an old one.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-03-22 21:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2007-03-22 21:58     ` Nikolai Weibull

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).