aboutsummaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-04-06 00:43:44 -0700
committerJunio C Hamano <gitster@pobox.com>2009-04-06 00:43:44 -0700
commitfbdc05661d9b732d06c47ccb3d5836d0d1b563e5 (patch)
treeb5e7e00ca449758d6244a382a27e9b967286787a /builtin-checkout.c
parent03a39a91842cf745e5fc27dbd6485aad44d839a4 (diff)
parent3e262b95c50991de12cc5e180b72256561606a19 (diff)
downloadgit-fbdc05661d9b732d06c47ccb3d5836d0d1b563e5.tar.gz
git-fbdc05661d9b732d06c47ccb3d5836d0d1b563e5.tar.xz
Merge branch 'jc/name-branch'
* jc/name-branch: Don't permit ref/branch names to end with ".lock" check_ref_format(): tighten refname rules strbuf_check_branch_ref(): a helper to check a refname for a branch Fix branch -m @{-1} newname check-ref-format --branch: give Porcelain a way to grok branch shorthand strbuf_branchname(): a wrapper for branch name shorthands Rename interpret/substitute nth_last_branch functions Conflicts: Documentation/git-check-ref-format.txt
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c18
1 files changed, 6 insertions, 12 deletions
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);
}