From: "Carlos Martín Nieto" <cmn@elego.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH] Allow cloning branches selectively
Date: Sun, 25 Dec 2011 20:37:40 +0000 [thread overview]
Message-ID: <20111225203740.GD6361@beez.lab.cmartin.tk> (raw)
In-Reply-To: <7vmxajaswj.fsf@alter.siamese.dyndns.org>
[-- Attachment #1: Type: text/plain, Size: 3455 bytes --]
On Fri, Dec 23, 2011 at 01:18:36PM -0800, Junio C Hamano wrote:
> 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.
The main usefulness is indeed to track single branches. Limiting it to
one looked to me to be an arbitrary limitation and I don't like
those. Tracking between two and all branches is probably quite a niche
however, so I'll go with allowing one -t/--track option and if enough
people want to extend it, we'll see what we do then.
>
> 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 &&
As Jakub pointed out, remote already has this option, so you can
replace these calls with
git remote add origin $there -t $it -m $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
A lazier man (or one who doesn't work with internals every day) might do
git checkout -t origin/$it
which the documentation claims would do the same thing. So it boils
down to doing three commands and it feels like it'd be much easier to
just write a small script than to modify the clone code. Putting it in
C will hopefully make the code a bit cleaner, if I use the code that
already exists in remote.
>
> 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.
Looking at the explanation for the -t (--track) option in git-remote,
it's certainly not very friendly unless you already know exactly what
a -t option would do if you were to implement it.
cmn
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
next prev parent reply other threads:[~2011-12-25 20:37 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
2011-12-25 20:37 ` Carlos Martín Nieto [this message]
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=20111225203740.GD6361@beez.lab.cmartin.tk \
--to=cmn@elego.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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).