]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/checkout.c
Prevent force-updating of the current branch
[thirdparty/git.git] / builtin / checkout.c
index ca855d716ccab1d1209638193e2f52e901acfba0..ddefec053e563dff0e16cd5adb2f8f6d26c77d87 100644 (file)
@@ -1071,15 +1071,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 
        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);
+
                strbuf_release(&buf);
        }