Re: Bug: "git checkout -b" should be allowed in empty repo
- From
Jeff King <peff@peff.net>
- Date
- Jan 30, 2012, 21:50 UTC
- Message-ID
- <20120130215043.GB16149@sigill.intra.peff.net>
- In-Reply-To
- <7vaa55ar4v.fsf@alter.siamese.dyndns.org>
On Mon, Jan 30, 2012 at 12:10:08PM -0800, Junio C Hamano wrote:
Show 20 quoted lines
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index f1984d9..195c40b 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -922,6 +922,19 @@ static int parse_branchname_arg(int argc, const char **argv,
> return argcount;
> }
>
> +static int switch_unborn_to_new_branch(struct checkout_opts *opts, const char *old_ref)
> +{
> + int status;
> + struct strbuf branch_ref = STRBUF_INIT;
> +
> + strbuf_addf(&branch_ref, "refs/heads/%s", opts->new_branch);
> + warning(_("Leaving the unborn branch '%s' behind..."),
> + skip_prefix(old_ref, "refs/heads/"));
> + status = create_symref("HEAD", branch_ref.buf, "checkout -b");
> + strbuf_reset(&branch_ref);
> + return status;
> +}Is it really worth warning? After all, by definition you are not leaving any commits or useful work behind.
Also, this has the same strbuf reset/release leak as the last patch. :)
-Peff