* [PATCH] Add --track option to git clone
@ 2009-11-30 13:16 David Soria Parra
2009-11-30 13:16 ` [PATCH 1/2] Teach clone to clone just one remote branch using --track David Soria Parra
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: David Soria Parra @ 2009-11-30 13:16 UTC (permalink / raw)
To: git
The following series adds a --track option to git clone. If the --track option
is specified only the given remote branch will be received and checked out.
It tries to make the following usecase possible:
Imagine you are working on a project that has 1.x and a 2.x branch. The project
itself requires a complex setup (webserver, configuration files, etc). Setting up
1.x and 2.x branch requires a lot of work, but a developer needs to maintain both.
He'll use the --track option to clone the 2.x branch into a directory and does the same
with the 1.x branch, where he setup the project. He can use locally separate repositories
while still being able to push to just one remote repository.
I'm aware that it's not possible to give more than one --track option. Implementing
the possibility to specify multiple --track option would certainly a good improvment
later, but would also require a lot more work as far as I understand the clone code.
Being able to specify just one --track option is a compromise of doing a small change
and implementing this feature.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] Teach clone to clone just one remote branch using --track
2009-11-30 13:16 [PATCH] Add --track option to git clone David Soria Parra
@ 2009-11-30 13:16 ` David Soria Parra
2009-11-30 13:16 ` [PATCH 2/2] Documentation: Add --track option to the git clone manpage David Soria Parra
2009-11-30 13:36 ` [PATCH] Add --track option to git clone Michael J Gruber
2 siblings, 0 replies; 4+ messages in thread
From: David Soria Parra @ 2009-11-30 13:16 UTC (permalink / raw)
To: git; +Cc: David Soria Parra
From: David Soria Parra <dsp@php.net>
Add a --track option that can be used to clone just the
given branch from the remote and nothing else. This is done
by setting the remote.<branch>.fetch option before cloning.
This option cannot be used together with --mirror.
For example using
git clone --track next git://git.kernel.org/pub/scm/git/git.git
will just clone the next branch from the git.git repository.
The option is called --track to ensure clean wording with
'git remote add --track'.
Signed-off-by: David Soria Parra <dsp@php.net>
---
builtin-clone.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c
index 5df8b0f..bc335ee 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -43,6 +43,7 @@ static char *option_template, *option_reference, *option_depth;
static char *option_origin = NULL;
static char *option_branch = NULL;
static char *option_upload_pack = "git-upload-pack";
+static char *option_track = NULL;
static int option_verbose;
static struct option builtin_clone_options[] = {
@@ -76,6 +77,8 @@ static struct option builtin_clone_options[] = {
"path to git-upload-pack on the remote"),
OPT_STRING(0, "depth", &option_depth, "depth",
"create a shallow clone of that depth"),
+ OPT_STRING('t', "track", &option_track, "branch",
+ "remote branche to track"),
OPT_END()
};
@@ -483,7 +486,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
strbuf_addf(&branch_top, "refs/remotes/%s/", option_origin);
}
- strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
+ if (option_track) {
+ if (option_mirror)
+ return error("Cannot use --track together with --mirror");
+ strbuf_addf(&value, "+%s%s:%s%s", src_ref_prefix, option_track, branch_top.buf, option_track);
+ option_branch = option_track;
+ } else {
+ strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top.buf);
+ }
if (option_mirror || !option_bare) {
/* Configure the remote */
--
1.6.6.rc0.268.g1c272
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] Documentation: Add --track option to the git clone manpage
2009-11-30 13:16 [PATCH] Add --track option to git clone David Soria Parra
2009-11-30 13:16 ` [PATCH 1/2] Teach clone to clone just one remote branch using --track David Soria Parra
@ 2009-11-30 13:16 ` David Soria Parra
2009-11-30 13:36 ` [PATCH] Add --track option to git clone Michael J Gruber
2 siblings, 0 replies; 4+ messages in thread
From: David Soria Parra @ 2009-11-30 13:16 UTC (permalink / raw)
To: git; +Cc: David Soria Parra
From: David Soria Parra <dsp@php.net>
Signed-off-by: David Soria Parra <dsp@php.net>
---
Documentation/git-clone.txt | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index 7e7d9fc..3c2e1b8 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -12,7 +12,7 @@ SYNOPSIS
'git clone' [--template=<template_directory>]
[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
[-o <name>] [-u <upload-pack>] [--reference <repository>]
- [--depth <depth>] [--recursive] [--] <repository> [<directory>]
+ [-t <name>] [--depth <depth>] [--recursive] [--] <repository> [<directory>]
DESCRIPTION
-----------
@@ -135,6 +135,12 @@ objects from the source repository into a pack in the cloned repository.
instead. In a non-bare repository, this is the branch that will
be checked out.
+--track <name>::
+-t <name>::
+ Instead of cloning the complete remote repository, only the given
+ remote branch `<name>` will be tracked and checked out.
+ This implies --branch `<name>`.
+
--upload-pack <upload-pack>::
-u <upload-pack>::
When given, and the repository to clone from is accessed
--
1.6.6.rc0.268.g1c272
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Add --track option to git clone
2009-11-30 13:16 [PATCH] Add --track option to git clone David Soria Parra
2009-11-30 13:16 ` [PATCH 1/2] Teach clone to clone just one remote branch using --track David Soria Parra
2009-11-30 13:16 ` [PATCH 2/2] Documentation: Add --track option to the git clone manpage David Soria Parra
@ 2009-11-30 13:36 ` Michael J Gruber
2 siblings, 0 replies; 4+ messages in thread
From: Michael J Gruber @ 2009-11-30 13:36 UTC (permalink / raw)
To: David Soria Parra; +Cc: git
David Soria Parra venit, vidit, dixit 30.11.2009 14:16:
> The following series adds a --track option to git clone. If the --track option
> is specified only the given remote branch will be received and checked out.
>
> It tries to make the following usecase possible:
> Imagine you are working on a project that has 1.x and a 2.x branch. The project
> itself requires a complex setup (webserver, configuration files, etc). Setting up
> 1.x and 2.x branch requires a lot of work, but a developer needs to maintain both.
> He'll use the --track option to clone the 2.x branch into a directory and does the same
> with the 1.x branch, where he setup the project. He can use locally separate repositories
> while still being able to push to just one remote repository.
While I think the feature itself is useful, I don't think it's that
useful for the case you mention. If you clone all branches anyways
you're much better of using alternates or --reference, or the workdir
script in contrib/
> I'm aware that it's not possible to give more than one --track option. Implementing
> the possibility to specify multiple --track option would certainly a good improvment
> later, but would also require a lot more work as far as I understand the clone code.
>
> Being able to specify just one --track option is a compromise of doing a small change
> and implementing this feature.
That restriction makes a lot of sense. Two suggestions:
- How does one turn such a "partial" clone into a full one? That should
be documented somewhere (git config remote.origin.fetch
'+refs/heads/*:refs/remotes/origin/*').
- A test would be nice, which makes sure you clone what you think you clone.
Cheers,
Michael
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-11-30 13:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-30 13:16 [PATCH] Add --track option to git clone David Soria Parra
2009-11-30 13:16 ` [PATCH 1/2] Teach clone to clone just one remote branch using --track David Soria Parra
2009-11-30 13:16 ` [PATCH 2/2] Documentation: Add --track option to the git clone manpage David Soria Parra
2009-11-30 13:36 ` [PATCH] Add --track option to git clone Michael J Gruber
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).