Re: [PATCH] We do not like "HEAD" as a new branch name
Hi,
On Thu, 15 Dec 2005, Junio C Hamano wrote:
Show 6 quoted lines
> 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