From: Junio C Hamano Date: Thu, 16 Feb 2012 22:18:06 +0000 (-0800) Subject: Merge branch 'jc/checkout-out-of-unborn' into maint X-Git-Tag: v1.7.9.2~21 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=147d071816c7011d24c195a9d6fca251ad312532;p=git.git Merge branch 'jc/checkout-out-of-unborn' into maint * jc/checkout-out-of-unborn: git checkout -b: allow switching out of an unborn branch --- 147d071816c7011d24c195a9d6fca251ad312532 diff --cc builtin/checkout.c index f1984d993,b76e2c045..a76aa2a6f --- a/builtin/checkout.c +++ b/builtin/checkout.c @@@ -1093,5 -1100,13 +1104,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); }