Merge branch 'jc/branch-name-sanity'

"git branch" and "git checkout -b" are now forbidden from creating
a branch whose name is "HEAD".

* jc/branch-name-sanity:
  builtin/branch: remove redundant check for HEAD
  branch: correctly reject refs/heads/{-dash,HEAD}
  branch: split validate_new_branchname() into two
  branch: streamline "attr_only" handling in validate_new_branchname()
This commit is contained in:
Junio C Hamano
2017-11-28 13:41:49 +09:00
6 changed files with 106 additions and 43 deletions

View File

@ -1287,11 +1287,11 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
if (opts.new_branch) {
struct strbuf buf = STRBUF_INIT;
opts.branch_exists =
validate_new_branchname(opts.new_branch, &buf,
!!opts.new_branch_force,
!!opts.new_branch_force);
if (opts.new_branch_force)
opts.branch_exists = validate_branchname(opts.new_branch, &buf);
else
opts.branch_exists =
validate_new_branchname(opts.new_branch, &buf, 0);
strbuf_release(&buf);
}