git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Carlos Martín Nieto" <cmn@elego.de>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH] Allow cloning branches selectively
Date: Fri, 23 Dec 2011 13:18:36 -0800	[thread overview]
Message-ID: <7vmxajaswj.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1324671199-7074-1-git-send-email-cmn@elego.de> ("Carlos Martín Nieto"'s message of "Fri, 23 Dec 2011 20:13:19 +0000")

Carlos Martín Nieto <cmn@elego.de> writes:

> Sometimes it's useful to clone only a subset of branches from a remote
> we're cloning. Teach clone the --fetch option to select which branches
> should get fetched.

This is just a knee-jerk reaction without reading the patch text (which I
won't be doing over the holiday weekend anyway), but is the workflow of
the primarly intended audience to clone "a subset of branches" or "a
single branch"?

I have a slight suspicion that this started out as "I often want to create
a clone to _track_ a single branch, but because I am mucking with the code
related to cloning anyway, I might as well allow more than one to be
fetched, even though I do not have any need for that, somebody might find
it useful". And that is why it is important to answer the first question.

If the primary motivation is for a single branch, I suspect supporting
only a single branch and advertising the feature as "tracking only one
branch" might make it much easier to understand to the end users.

Upon "git clone --track cn/single-clone $there x.git", you would do
something like:

  it=cn/single-clone &&
  git init x.git &&
  cd x.git &&

  # configure "git fetch origin" to only get branch $it
  git config remote.origin.url "$there" &&
  git config remote.origin.fetch refs/heads/$it:refs/remotes/origin/$it &&

  # declare that the primary branch at origin is $it as far as we are concerned
  git symbolic-ref -m clone refs/remotes/origin/HEAD refs/remotes/origin/$it &&

  # Git aware prompt reminds us that this repository is to track branch $it
  git symbolic-ref -m clone HEAD refs/heads/$it &&

  # And Go!
  git fetch origin &&
  git reset --hard remotes/origin/$it &&
  git config branch.$it.remote origin &&
  git config branch.$it.merge $it

Of course you _could_ support more than one pretty easily, but the point
is that it is unclear how you explain to the end user what the feature
does and what it is for in easily understoodd terms, once you start doing
so. It will no longer be "this new clone is to track that branch", but
something else, and I do not know what that something else is.

And depending on what that "something else" is, which branch should be
checked out and what refs/remotes/origin/HEAD should name as the primary
branch of the remote would be different.

Thanks.

  reply	other threads:[~2011-12-23 21:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-23 20:13 [RFC PATCH] Allow cloning branches selectively Carlos Martín Nieto
2011-12-23 21:18 ` Junio C Hamano [this message]
2011-12-25 20:37   ` Carlos Martín Nieto
2011-12-24  4:31 ` Nguyen Thai Ngoc Duy
2011-12-25 19:00   ` Carlos Martín Nieto
2011-12-25 16:28 ` Jakub Narebski
2011-12-25 17:43   ` Carlos Martín Nieto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vmxajaswj.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=cmn@elego.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).