X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-checkout.c;h=33d1fecb6251b4922666255817addeb9f672fa29;hb=46ae156d6c8c48d521e4d858ed84d93259cfc61f;hp=fc55bbe14d58df66e71a9e1975bb7c4eecdc1a49;hpb=f23336f5c15eb90df3275076181d10746479be5b;p=git.git diff --git a/builtin-checkout.c b/builtin-checkout.c index fc55bbe14..33d1fecb6 100644 --- a/builtin-checkout.c +++ b/builtin-checkout.c @@ -353,16 +353,11 @@ struct branch_info { static void setup_branch_path(struct branch_info *branch) { struct strbuf buf = STRBUF_INIT; - int ret; - if ((ret = interpret_nth_last_branch(branch->name, &buf)) - && ret == strlen(branch->name)) { + strbuf_branchname(&buf, branch->name); + if (strcmp(buf.buf, branch->name)) branch->name = xstrdup(buf.buf); - strbuf_splice(&buf, 0, 0, "refs/heads/", 11); - } else { - strbuf_addstr(&buf, "refs/heads/"); - strbuf_addstr(&buf, branch->name); - } + strbuf_splice(&buf, 0, 0, "refs/heads/", 11); branch->path = strbuf_detach(&buf, NULL); } @@ -738,12 +733,11 @@ no_reference: if (opts.new_branch) { struct strbuf buf = STRBUF_INIT; - strbuf_addstr(&buf, "refs/heads/"); - strbuf_addstr(&buf, opts.new_branch); + 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 (!get_sha1(buf.buf, rev)) die("git checkout: branch %s already exists", opts.new_branch); - if (check_ref_format(buf.buf)) - die("git checkout: we do not like '%s' as a branch name.", opts.new_branch); strbuf_release(&buf); }