git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add option -b/--branch to clone for select a new HEAD

From
Jeff King <peff@peff.net>
Date
Aug 25, 2009, 01:57 UTC
Message-ID
<20090825015726.GB7655@coredump.intra.peff.net>
In-Reply-To
<1251146568-25248-1-git-send-email-catap@catap.ru>
On Tue, Aug 25, 2009 at 12:42:48AM +0400, Kirill A. Korinskiy wrote:
Show 5 quoted lines
> Sometimes (especially on production systems) we need to use only one
> remote branch for building software. It really annoying to clone
> origin and then swith branch by hand everytime. So this patch provide
> functionality to clone remote branch with one command without using
> checkout after clone.

If you are doing this a lot, it is probably a sign that you should repoint the "HEAD" of the parent repository.

That being said, you may want one branch half the time, and another branch the other half. So I think this is a good feature.

A few comments:
> ---
>  Documentation/git-clone.txt |    4 ++++
>  builtin-clone.c             |   26 +++++++++++++++++++++++---
>  2 files changed, 27 insertions(+), 3 deletions(-)
Tests?
> -	const struct ref *refs, *head_points_at, *remote_head, *mapped_refs;
> -	struct strbuf key = STRBUF_INIT, value = STRBUF_INIT;
> +	const struct ref *refs, *head_points_at, *remote_head = NULL, *mapped_refs;
> +	struct strbuf key = STRBUF_INIT, value = STRBUF_INIT, branch_head = STRBUF_INIT;

Style nit: I don't know if we have a style guideline for declaring variables, but I find these "many variables on a line" declarations annoying for reviewing, since it is hard to see what actually changed (and yes, you only added a declaration on one, so I am partially complaining about the person who came before you :) ).

> +		if (option_branch)
> +			die("--bare and --branch %s options are incompatible.",
> +			    option_branch);

Hmm. Would it perhaps make sense to have "--bare --branch foo" point the HEAD of the newly created bare repo, but not impact the (nonexistent) working tree?

-Peff
Previous: Kirill A. KorinskiyNext: Junio C Hamano
Message 2 of 6 in “Add option -b/--branch to clone for select a new HEAD”
  1. Add option -b/--branch to clone for select a new HEADKirill A. Korinskiy, Aug 24, 2009
  2. Jeff KingAug 25, 2009
  3. Junio C HamanoAug 25, 2009
  4. Add option -b/--branch to clone for select a new HEADKirill A. Korinskiy, Aug 25, 2009
  5. Jeff KingAug 25, 2009
  6. Add option -b/--branch to clone for select a new HEADKirill A. Korinskiy, Aug 25, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.