Re: [PATCH] We do not like "HEAD" as a new branch name

From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Date: 2005-12-16 03:40:05
Hi,

On Thu, 15 Dec 2005, H. Peter Anvin wrote:

> 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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Fri Dec 16 03:40:46 2005

This archive was generated by hypermail 2.1.8 : 2005-12-16 03:40:53 EST