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

[PATCH] disallow branch names that start with a hyphen

From
Clemens Buchacher <drizzd@aon.at>
Date
Aug 22, 2010, 14:08 UTC
Message-ID
<20100822140801.GA6574@localhost>

Branch names such as "-", "--" or even "---" do not work with git checkout. Anything that starts with a hyphen is also potentially ambiguous with a command option.

In order to avoid mistakes, do not allow such branch names.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
 refs.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/refs.c b/refs.c
index b540067..6884dff 100644
--- a/refs.c
+++ b/refs.c
@@ -742,7 +742,7 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
  * Make sure "ref" is something reasonable to have under ".git/refs/";
  * We do not like it if:
  *
- * - any path component of it begins with ".", or
+ * - any path component of it begins with "." or "-", or
  * - it has double dots "..", or
  * - it has ASCII control character, "~", "^", ":" or SP, anywhere, or
  * - it ends with a "/".
@@ -778,7 +778,7 @@ int check_ref_format(const char *ref)
 			return CHECK_REF_FORMAT_ERROR;
 
 		/* we are at the beginning of the path component */
-		if (ch == '.')
+		if (ch == '.' || ch == '-')
 			return CHECK_REF_FORMAT_ERROR;
 		bad_type = bad_ref_char(ch);
 		if (bad_type) {
-- 
1.7.2.1.1.g202c
Next: Junio C Hamano
Message 1 of 6 in “disallow branch names that start with a hyphen”
  1. disallow branch names that start with a hyphenClemens Buchacher, Aug 22, 2010
  2. Junio C HamanoAug 22, 2010
  3. Clemens BuchacherAug 23, 2010
  4. Junio C HamanoSep 14, 2010
  5. Jakub NarebskiSep 14, 2010
  6. Clemens BuchacherSep 15, 2010

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.