From: Junio C Hamano Date: Mon, 13 Feb 2012 06:43:44 +0000 (-0800) Subject: Merge branch 'jc/checkout-out-of-unborn' X-Git-Tag: v1.7.10-rc0~90 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=aa47ec99d1ef979bbf5eca93c0152dd0e636b605;p=git.git Merge branch 'jc/checkout-out-of-unborn' * jc/checkout-out-of-unborn: git checkout -b: allow switching out of an unborn branch --- aa47ec99d1ef979bbf5eca93c0152dd0e636b605 diff --cc builtin/checkout.c index 5bf96ba4d,b76e2c045..6b9061f26 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@@ -1079,5 -1100,13 +1090,13 @@@ int cmd_checkout(int argc, const char * if (opts.writeout_stage) die(_("--ours/--theirs is incompatible with switching branches.")); + if (!new.commit) { + unsigned char rev[20]; + int flag; + - resolve_ref("HEAD", rev, 0, &flag); - if ((flag & REF_ISSYMREF) && is_null_sha1(rev)) ++ if (!read_ref_full("HEAD", rev, 0, &flag) && ++ (flag & REF_ISSYMREF) && is_null_sha1(rev)) + return switch_unborn_to_new_branch(&opts); + } return switch_branches(&opts, &new); }