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 --- 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