git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 16, 2005, 01:40 UTC
Message-ID
<Pine.LNX.4.63.0512160238300.6530@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7v4q5alyms.fsf@assigned-by-dhcp.cox.net>
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
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 10 in “We do not like "HEAD" as a new branch name”
  1. We do not like "HEAD" as a new branch nameJohannes Schindelin, Dec 15, 2005
  2. H. Peter AnvinDec 15, 2005
  3. Johannes SchindelinDec 15, 2005
  4. Alex RiesenDec 15, 2005
  5. Junio C HamanoDec 15, 2005
  6. Johannes SchindelinDec 15, 2005
  7. Junio C HamanoDec 15, 2005
  8. Johannes SchindelinDec 16, 2005
  9. Junio C HamanoDec 16, 2005
  10. Johannes SchindelinDec 16, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.