@matheusbsbs / matheus-bagliano / commits / ee34518d62
Fork 0

We do not like "HEAD" as a new branch name

This makes git-check-ref-format fail for "HEAD". Since the check is only executed when creating refs, the existing symbolic ref is safe. Otherwise these commands, most likely are pilot errors, would do pretty funky stuff: git checkout -b HEAD git pull . other:HEAD Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Dec 16, 2005 at 02:40 UTC ee34518d629331dadd58b1a75294369d679eda8b
1 file changed +5
refs.c
+5
@@ -345,6 +345,11 @@ int check_ref_format(const char *ref)
345 if (!ch) {
346 if (level < 2)
347 return -1; /* at least of form "heads/blah" */
348 +
349 + /* do not allow ref name to end in "HEAD" */
350 + if (cp - ref > 4 && !strcmp(cp - 4, "HEAD"))
351 + return -1;
352 +
353 return 0;
354 }
355 }