diff --git a/builtin/checkout.c b/builtin/checkout.c
index 4eaedff0c47cbc8ab38e4c1ec813b1f7a248cdff..5e356a6c6178e08b90d992b0eae36048b5d81513 100644 (file)
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
if (opts.new_branch) {
struct strbuf buf = STRBUF_INIT;
- if (strbuf_check_branch_ref(&buf, opts.new_branch))
- die(_("git checkout: we do not like '%s' as a branch name."),
- opts.new_branch);
- if (ref_exists(buf.buf)) {
- opts.branch_exists = 1;
- if (!opts.new_branch_force)
- die(_("git checkout: branch %s already exists"),
- opts.new_branch);
- }
+
+ opts.branch_exists = validate_new_branchname(opts.new_branch, &buf,
+ !!opts.new_branch_force, 0);
+
strbuf_release(&buf);
}