summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-01-20 15:15:40 +0000
committerGitHub <noreply@github.com>2018-01-20 15:15:40 +0000
commit45f584090818c59ba27ca95b1e930a41c424d6f1 (patch)
tree2b4c4cf8a2414e3a9246a1cfec6eeba956308a11
parent4ea8035dcf7fed2f08f050a5e54149090c748aac (diff)
parenta9677e019c01cc9c06230c4e8ee2c04db72885c4 (diff)
downloadlibgit2-45f584090818c59ba27ca95b1e930a41c424d6f1.tar.gz
Merge pull request #4484 from pks-t/pks/fail-creating-branch-HEAD
branch: refuse creating branches named 'HEAD'
-rw-r--r--src/branch.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/branch.c b/src/branch.c
index 0697a77fb..42addc2ce 100644
--- a/src/branch.c
+++ b/src/branch.c
@@ -70,6 +70,12 @@ static int create_branch(
assert(branch_name && commit && ref_out);
assert(git_object_owner((const git_object *)commit) == repository);
+ if (!git__strcmp(branch_name, "HEAD")) {
+ giterr_set(GITERR_REFERENCE, "'HEAD' is not a valid branch name");
+ error = -1;
+ goto cleanup;
+ }
+
if (force && !bare && git_branch_lookup(&branch, repository, branch_name, GIT_BRANCH_LOCAL) == 0) {
error = git_branch_is_head(branch);
git_reference_free(branch);