diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/branch.c | 6 | ||||
-rw-r--r-- | builtin/checkout.c | 12 |
2 files changed, 4 insertions, 14 deletions
diff --git a/builtin/branch.c b/builtin/branch.c index f7da69c932..aa705a0fb0 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -566,11 +566,7 @@ static void rename_branch(const char *oldname, const char *newname, int force) die(_("Invalid branch name: '%s'"), oldname); } - if (strbuf_check_branch_ref(&newref, newname)) - die(_("Invalid branch name: '%s'"), newname); - - if (resolve_ref(newref.buf, sha1, 1, NULL) && !force) - die(_("A branch named '%s' already exists."), newref.buf + 11); + validate_new_branchname(newname, &newref, force); strbuf_addf(&logmsg, "Branch: renamed %s to %s", oldref.buf, newref.buf); diff --git a/builtin/checkout.c b/builtin/checkout.c index 4eaedff0c4..3bb652591b 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -1072,15 +1072,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); } |