Re: Bug: "git checkout -b" should be allowed in empty repo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 30, 2012 at 12:10:08PM -0800, Junio C Hamano wrote:

> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]