Skip to content

Commit 08986de

Browse files
committed
Merge branch 'jc/no-branch-name-with-dash-at-front'
* jc/no-branch-name-with-dash-at-front: disallow branch names that start with a hyphen
2 parents 0ff4bdb + 6348624 commit 08986de

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

strbuf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ int strbuf_branchname(struct strbuf *sb, const char *name)
399399
int strbuf_check_branch_ref(struct strbuf *sb, const char *name)
400400
{
401401
strbuf_branchname(sb, name);
402+
if (name[0] == '-')
403+
return CHECK_REF_FORMAT_ERROR;
402404
strbuf_splice(sb, 0, 0, "refs/heads/", 11);
403405
return check_ref_format(sb->buf);
404406
}

0 commit comments

Comments
 (0)