File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,11 @@ static int not_a_local_branch(const char *reference_name)
5252 return -1 ;
5353}
5454
55+ static bool branch_name_follows_pattern (const char * branch_name )
56+ {
57+ return branch_name [0 ] != '-' && git__strcmp (branch_name , "HEAD" );
58+ }
59+
5560static int create_branch (
5661 git_reference * * ref_out ,
5762 git_repository * repository ,
@@ -72,7 +77,7 @@ static int create_branch(
7277 GIT_ASSERT_ARG (ref_out );
7378 GIT_ASSERT_ARG (git_commit_owner (commit ) == repository );
7479
75- if (!git__strcmp (branch_name , "HEAD" )) {
80+ if (!branch_name_follows_pattern (branch_name )) {
7681 git_error_set (GIT_ERROR_REFERENCE , "'HEAD' is not a valid branch name" );
7782 error = -1 ;
7883 goto cleanup ;
@@ -762,7 +767,7 @@ int git_branch_name_is_valid(int *valid, const char *name)
762767 * and discourage HEAD as branch name,
763768 * https://github.com/git/git/commit/a625b092cc5994
764769 */
765- if (!name || name [ 0 ] == '-' || ! git__strcmp (name , "HEAD" ))
770+ if (!name || ! branch_name_follows_pattern (name ))
766771 goto done ;
767772
768773 if ((error = git_buf_puts (& ref_name , GIT_REFS_HEADS_DIR )) < 0 ||
You can’t perform that action at this time.
0 commit comments