Skip to content

Commit 45f5840

Browse files
authored
Merge pull request libgit2#4484 from pks-t/pks/fail-creating-branch-HEAD
branch: refuse creating branches named 'HEAD'
2 parents 4ea8035 + a9677e0 commit 45f5840

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/branch.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ static int create_branch(
7070
assert(branch_name && commit && ref_out);
7171
assert(git_object_owner((const git_object *)commit) == repository);
7272

73+
if (!git__strcmp(branch_name, "HEAD")) {
74+
giterr_set(GITERR_REFERENCE, "'HEAD' is not a valid branch name");
75+
error = -1;
76+
goto cleanup;
77+
}
78+
7379
if (force && !bare && git_branch_lookup(&branch, repository, branch_name, GIT_BRANCH_LOCAL) == 0) {
7480
error = git_branch_is_head(branch);
7581
git_reference_free(branch);

0 commit comments

Comments
 (0)