{"thread":{"id":"21795","subject":"[PATCH] Add --track option to git clone","startedAt":"2009-11-30T13:16:42Z","lastAt":"2009-11-30T13:36:40Z","messageCount":4,"participants":["David Soria Parra","Michael J Gruber"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"128765","messageId":"1259587004-14633-1-git-send-email-sn_@gmx.net","threadId":"21795","inReplyTo":null,"subject":"[PATCH] Add --track option to git clone","fromName":"David Soria Parra","fromEmail":"sn_@gmx.net","sentAt":"2009-11-30T13:16:42Z","receivedAt":"2009-11-30T13:16:42Z","isPatch":true,"sender":{"key":"sn_@gmx.net","avatar":"https://gravatar.com/avatar/b1075ecdd33ea094cbc23798fe8b95c73ec1ccf7bb213ac8260c719e2dd97b55?d=mp&s=160"},"body":"The following series adds a --track option to git clone. If the --track option\nis specified only the given remote branch will be received and checked out.\n\nIt tries to make the following usecase possible:\nImagine you are working on a project that has 1.x and a 2.x branch. The project\nitself requires a complex setup (webserver, configuration files, etc). Setting up\n1.x and 2.x branch requires a lot of work, but a developer needs to maintain both.\nHe'll use the --track option to clone the 2.x branch into a directory and does the same\nwith the 1.x branch, where he setup the project. He can use locally separate repositories\nwhile still being able to push to just one remote repository.\n\nI'm aware that it's not possible to give more than one --track option. Implementing\nthe possibility to specify multiple --track option would certainly a good improvment\nlater, but would also require a lot more work as far as I understand the clone code.\n\nBeing able to specify just one --track option is a compromise of doing a small change\nand implementing this feature.\n"},{"id":"128766","messageId":"1259587004-14633-2-git-send-email-sn_@gmx.net","threadId":"21795","inReplyTo":"1259587004-14633-1-git-send-email-sn_@gmx.net","subject":"[PATCH 1/2] Teach clone to clone just one remote branch using --track","fromName":"David Soria Parra","fromEmail":"sn_@gmx.net","sentAt":"2009-11-30T13:16:43Z","receivedAt":"2009-11-30T13:16:43Z","isPatch":true,"sender":{"key":"sn_@gmx.net","avatar":"https://gravatar.com/avatar/b1075ecdd33ea094cbc23798fe8b95c73ec1ccf7bb213ac8260c719e2dd97b55?d=mp&s=160"},"body":"From: David Soria Parra <dsp@php.net>\n\nAdd a --track option that can be used to clone just the\ngiven branch from the remote and nothing else. This is done\nby setting the remote.<branch>.fetch option before cloning.\nThis option cannot be used together with --mirror.\nFor example using\n\n    git clone --track next git://git.kernel.org/pub/scm/git/git.git\n\nwill just clone the next branch from the git.git repository.\n\nThe option is called --track to ensure clean wording with\n'git remote add --track'.\n\nSigned-off-by: David Soria Parra <dsp@php.net>\n---\n builtin-clone.c |   12 +++++++++++-\n 1 files changed, 11 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex 5df8b0f..bc335ee 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -43,6 +43,7 @@ static char *option_template, *option_reference, *option_depth;\n static char *option_origin = NULL;\n static char *option_branch = NULL;\n static char *option_upload_pack = \"git-upload-pack\";\n+static char *option_track = NULL;\n static int option_verbose;\n \n static struct option builtin_clone_options[] = {\n@@ -76,6 +77,8 @@ static struct option builtin_clone_options[] = {\n \t\t   \"path to git-upload-pack on the remote\"),\n \tOPT_STRING(0, \"depth\", &option_depth, \"depth\",\n \t\t    \"create a shallow clone of that depth\"),\n+\tOPT_STRING('t', \"track\", &option_track, \"branch\",\n+\t\t\t\"remote branche to track\"),\n \n \tOPT_END()\n };\n@@ -483,7 +486,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\tstrbuf_addf(&branch_top, \"refs/remotes/%s/\", option_origin);\n \t}\n \n-\tstrbuf_addf(&value, \"+%s*:%s*\", src_ref_prefix, branch_top.buf);\n+\tif (option_track) {\n+\t\tif (option_mirror)\n+\t\t\treturn error(\"Cannot use --track together with --mirror\");\n+\t\tstrbuf_addf(&value, \"+%s%s:%s%s\", src_ref_prefix, option_track, branch_top.buf, option_track);\n+\t\toption_branch = option_track;\n+\t} else {\n+\t\tstrbuf_addf(&value, \"+%s*:%s*\", src_ref_prefix, branch_top.buf);\n+\t}\n \n \tif (option_mirror || !option_bare) {\n \t\t/* Configure the remote */\n-- \n1.6.6.rc0.268.g1c272\n"},{"id":"128767","messageId":"1259587004-14633-3-git-send-email-sn_@gmx.net","threadId":"21795","inReplyTo":"1259587004-14633-1-git-send-email-sn_@gmx.net","subject":"[PATCH 2/2] Documentation: Add --track option to the git clone manpage","fromName":"David Soria Parra","fromEmail":"sn_@gmx.net","sentAt":"2009-11-30T13:16:44Z","receivedAt":"2009-11-30T13:16:44Z","isPatch":true,"sender":{"key":"sn_@gmx.net","avatar":"https://gravatar.com/avatar/b1075ecdd33ea094cbc23798fe8b95c73ec1ccf7bb213ac8260c719e2dd97b55?d=mp&s=160"},"body":"From: David Soria Parra <dsp@php.net>\n\nSigned-off-by: David Soria Parra <dsp@php.net>\n---\n Documentation/git-clone.txt |    8 +++++++-\n 1 files changed, 7 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt\nindex 7e7d9fc..3c2e1b8 100644\n--- a/Documentation/git-clone.txt\n+++ b/Documentation/git-clone.txt\n@@ -12,7 +12,7 @@ SYNOPSIS\n 'git clone' [--template=<template_directory>]\n \t  [-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]\n \t  [-o <name>] [-u <upload-pack>] [--reference <repository>]\n-\t  [--depth <depth>] [--recursive] [--] <repository> [<directory>]\n+\t  [-t <name>] [--depth <depth>] [--recursive] [--] <repository> [<directory>]\n \n DESCRIPTION\n -----------\n@@ -135,6 +135,12 @@ objects from the source repository into a pack in the cloned repository.\n \tinstead. In a non-bare repository, this is the branch that will\n \tbe checked out.\n \n+--track <name>::\n+-t <name>::\n+\tInstead of cloning the complete remote repository, only the given\n+\tremote branch `<name>` will be tracked and checked out.\n+\tThis implies --branch `<name>`.\n+\n --upload-pack <upload-pack>::\n -u <upload-pack>::\n \tWhen given, and the repository to clone from is accessed\n-- \n1.6.6.rc0.268.g1c272\n"},{"id":"128770","messageId":"4B13CA68.70708@drmicha.warpmail.net","threadId":"21795","inReplyTo":"1259587004-14633-1-git-send-email-sn_@gmx.net","subject":"Re: [PATCH] Add --track option to git clone","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-11-30T13:36:40Z","receivedAt":"2009-11-30T13:36:40Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"David Soria Parra venit, vidit, dixit 30.11.2009 14:16:\n> The following series adds a --track option to git clone. If the --track option\n> is specified only the given remote branch will be received and checked out.\n> \n> It tries to make the following usecase possible:\n> Imagine you are working on a project that has 1.x and a 2.x branch. The project\n> itself requires a complex setup (webserver, configuration files, etc). Setting up\n> 1.x and 2.x branch requires a lot of work, but a developer needs to maintain both.\n> He'll use the --track option to clone the 2.x branch into a directory and does the same\n> with the 1.x branch, where he setup the project. He can use locally separate repositories\n> while still being able to push to just one remote repository.\n\nWhile I think the feature itself is useful, I don't think it's that\nuseful for the case you mention. If you clone all branches anyways\nyou're much better of using alternates or --reference, or the workdir\nscript in contrib/\n\n> I'm aware that it's not possible to give more than one --track option. Implementing\n> the possibility to specify multiple --track option would certainly a good improvment\n> later, but would also require a lot more work as far as I understand the clone code.\n> \n> Being able to specify just one --track option is a compromise of doing a small change\n> and implementing this feature.\n\nThat restriction makes a lot of sense. Two suggestions:\n\n- How does one turn such a \"partial\" clone into a full one? That should\nbe documented somewhere (git config remote.origin.fetch\n'+refs/heads/*:refs/remotes/origin/*').\n\n- A test would be nice, which makes sure you clone what you think you clone.\n\nCheers,\nMichael\n"}]}