Code

Merge branch 'jc/checkout-out-of-unborn'
authorJunio C Hamano <gitster@pobox.com>
Mon, 13 Feb 2012 06:43:44 +0000 (22:43 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Feb 2012 06:43:45 +0000 (22:43 -0800)
* jc/checkout-out-of-unborn:
  git checkout -b: allow switching out of an unborn branch

1  2 
builtin/checkout.c

index 5bf96ba4d41cc9c16bb5ccabe9857724ecfe2c12,b76e2c0451cbeb73e1fd227c343413b1c8a33cc7..6b9061f26f5f33ae1ded811891e933441c210fb0
@@@ -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."));
  
 -              resolve_ref("HEAD", rev, 0, &flag);
 -              if ((flag & REF_ISSYMREF) && is_null_sha1(rev))
+       if (!new.commit) {
+               unsigned char rev[20];
+               int flag;
++              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);
  }