From: Johannes Schindelin Date: Fri, 16 Dec 2005 01:40:25 GMT Subject: Re: [PATCH] We do not like "HEAD" as a new branch name Message-ID: In-Reply-To: <7v4q5alyms.fsf@assigned-by-dhcp.cox.net> Hi, On Thu, 15 Dec 2005, Junio C Hamano wrote: > Just to futureproof ourselves, how about this? > > /^(?:.*/)?(?:[A-Z0-9]+_)?HEAD$/ > > The last path component being "HEAD" or capital-or-digit > followed by underscore followed by "HEAD". Okay. Why not go the full nine yards, and not be difficult about it: diff --git a/refs.c b/refs.c --- a/refs.c +++ b/refs.c @@ -345,6 +345,11 @@ int check_ref_format(const char *ref) if (!ch) { if (level < 2) return -1; /* at least of form "heads/blah" */ + + /* do not allow ref name to end in "HEAD" */ + if (cp - ref > 4 && !strcmp(cp - 4, "HEAD")) + return -1; + return 0; } } Ciao, Dscho