git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] disallow branch names that start with a hyphen
@ 2010-08-22 14:08 Clemens Buchacher
  2010-08-22 21:20 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Clemens Buchacher @ 2010-08-22 14:08 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Thomas Rast

[-- Attachment #1: Type: text/plain, Size: 1195 bytes --]


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


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-09-15  7:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-22 14:08 [PATCH] disallow branch names that start with a hyphen Clemens Buchacher
2010-08-22 21:20 ` Junio C Hamano
2010-08-23  4:37   ` Clemens Buchacher
2010-09-14 20:09     ` Junio C Hamano
2010-09-14 20:38       ` Jakub Narebski
2010-09-15  7:34       ` Clemens Buchacher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).