diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-09-21 23:50:05 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-09-21 23:50:05 -0700 |
commit | 666599d798102df2d7b32196cadb7dfb737e0b32 (patch) | |
tree | 21db458120cf33e1031f135f060d21805d3bb825 /builtin-checkout.c | |
parent | t5510: test "git fetch" following tags minimally (diff) | |
parent | Check early that a new branch is new and valid (diff) | |
download | tgif-666599d798102df2d7b32196cadb7dfb737e0b32.tar.xz |
Merge branch 'db/maint-checkout-b'
* db/maint-checkout-b:
Check early that a new branch is new and valid
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r-- | builtin-checkout.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c index 9377a1c71e..4497b7092d 100644 --- a/builtin-checkout.c +++ b/builtin-checkout.c @@ -580,6 +580,18 @@ no_reference: return checkout_paths(source_tree, pathspec); } + if (opts.new_branch) { + struct strbuf buf; + strbuf_init(&buf, 0); + strbuf_addstr(&buf, "refs/heads/"); + strbuf_addstr(&buf, 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); + } + if (new.name && !new.commit) { die("Cannot switch branch to a non-commit."); } |