Re: [PATCH] We do not like "HEAD" as a new branch name
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Dec 15, 2005, 16:40 UTC
- Message-ID
- <Pine.LNX.4.63.0512151737240.3542@wbgn013.biozentrum.uni-wuerzburg.de>
- In-Reply-To
- <43A19962.2000202@zytor.com>
Hi,
On Thu, 15 Dec 2005, H. Peter Anvin wrote:
Show 23 quoted lines
> Johannes Schindelin wrote:
> > This makes git-check-ref-format fail for "HEAD". Since the check is only
> > executed when creating refs, the existing symbolic ref is safe.
>
> > diff --git a/refs.c b/refs.c
> > index bda45f7..293bfe7 100644
> > --- a/refs.c
> > +++ b/refs.c
> > @@ -332,6 +332,11 @@ int check_ref_format(const char *ref)
> > if (ch == '.' || bad_ref_char(ch))
> > return -1;
> > + /* do not allow "HEAD" as ref name */
> > + if (ch == 'H' && (!strcmp(cp, "EAD") ||
> > + !strncmp(cp, "EAD/", 4)))
> > + return -1;
> > +
> > /* scan the rest of the path component */
> > while ((ch = *cp++) != 0) {
>
> If you're have to open-code it, you might want to just do it all the way:
>
> if (ch == 'H' && cp[0] == 'E' && cp[1] == 'A' && cp[2] == 'D' &&
> (cp[3] == '\0' || cp[3] == '/'));-)
I don't really care. I could have used !strcmp(cp - 1, "HEAD"), just as well...
Ciao, Dscho