summaryrefslogtreecommitdiff
path: root/compat/strtoimax.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-11-14 17:12:58 +0530
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-11-15 11:41:53 +0900
commita625b092cc59940521789fe8a3ff69c8d6b14eb2 (patch)
tree3df0f71f1729090dd80b2b4e80e8c95e8a691410 /compat/strtoimax.c
parentbranch: split validate_new_branchname() into two (diff)
downloadtgif-a625b092cc59940521789fe8a3ff69c8d6b14eb2.tar.xz
branch: correctly reject refs/heads/{-dash,HEAD}
strbuf_check_branch_ref() is the central place where many codepaths see if a proposed name is suitable for the name of a branch. It was designed to allow us to get stricter than the check_refname_format() check used for refnames in general, and we already use it to reject a branch whose name begins with a '-'. The function gets a strbuf and a string "name", and returns non-zero if the name is not appropriate as the name for a branch. When the name is good, it places the full refname for the branch with the proposed name in the strbuf before it returns. However, it turns out that one caller looks at what is in the strbuf even when the function returns an error. Make the function populate the strbuf even when it returns an error. That way, when "-dash" is given as name, "refs/heads/-dash" is placed in the strbuf when returning an error to copy_or_rename_branch(), which notices that the user is trying to recover with "git branch -m -- -dash dash" to rename "-dash" to "dash". While at it, use the same mechanism to also reject "HEAD" as a branch name. Helped-by: Jeff King <peff@peff.net> Helped-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/strtoimax.c')
0 files changed, 0 insertions, 0 deletions