summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-07-22 13:00:31 -0700
committerJunio C Hamano <gitster@pobox.com>2012-07-22 13:00:32 -0700
commit9ea5c632da283ff8c2dea8176cd34f1c8618d6c4 (patch)
tree98c421927ea754c8eeb2733a5ec7dc09825a1cdc /builtin
parentbb3ed291a6cfd4ed58773f2158f3ae32baf066e0 (diff)
parent8ced1aa08f9e1798b2b3fec41a0598ef79b477fe (diff)
downloadgit-9ea5c632da283ff8c2dea8176cd34f1c8618d6c4.tar.gz
Merge branch 'cw/no-detaching-an-unborn' into maint
"git checkout --detach", when you are still on an unborn branch, should be forbidden, but it wasn't. * cw/no-detaching-an-unborn: git-checkout: disallow --detach on unborn branch
Diffstat (limited to 'builtin')
-rw-r--r--builtin/checkout.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index e8c1b1f189..3980d5d06e 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -915,6 +915,8 @@ static int switch_unborn_to_new_branch(struct checkout_opts *opts)
int status;
struct strbuf branch_ref = STRBUF_INIT;
+ if (!opts->new_branch)
+ die(_("You are on a branch yet to be born"));
strbuf_addf(&branch_ref, "refs/heads/%s", opts->new_branch);
status = create_symref("HEAD", branch_ref.buf, "checkout -b");
strbuf_release(&branch_ref);