{"thread":{"id":"18025","subject":"Does cloning a shallow repo require special setting in the cloned one?","startedAt":"2009-02-26T03:49:06Z","lastAt":"2009-02-27T00:42:22Z","messageCount":8,"participants":["roylee17","Teemu Likonen","Roy Lee","Jeff King","Johannes Schindelin","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"106284","messageId":"1235620146513-2387799.post@n2.nabble.com","threadId":"18025","inReplyTo":null,"subject":"Does cloning a shallow repo require special setting in the cloned one?","fromName":"roylee17","fromEmail":"roylee17@gmail.com","sentAt":"2009-02-26T03:49:06Z","receivedAt":"2009-02-26T03:49:06Z","isPatch":false,"sender":{"key":"roylee17@gmail.com","avatar":null},"body":"\nHi,\n\nI have a question about cloning shallow repo.\n\n$ git clone --depth 1 git://git2.kernel.org/pub/scm/git/git.git git-shallow\nok, 'git log' gives a 2-revision history.\n\n$ git clone git://git2.kernel.org/pub/scm/git/git.git git-full\n'git log' gives a full history\n\n$ git clone --depth 1 git-full git-shallow2\n'git log' still gives a full history\n\nWhy can't I clone a shallow repo from the git-full?\nDoes it requires some settings in the git-full repo?\n\nRegards,\nRoy\nRoy\n-- \nView this message in context: http://n2.nabble.com/Does-cloning-a-shallow-repo-require-special-setting-in-the-cloned-one--tp2387799p2387799.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"106290","messageId":"87tz6hn1tg.fsf@iki.fi","threadId":"18025","inReplyTo":"1235620146513-2387799.post@n2.nabble.com","subject":"Re: Does cloning a shallow repo require special setting in the cloned one?","fromName":"Teemu Likonen","fromEmail":"tlikonen@iki.fi","sentAt":"2009-02-26T06:34:51Z","receivedAt":"2009-02-26T06:34:51Z","isPatch":false,"sender":{"key":"tlikonen@iki.fi","avatar":null},"body":"On 2009-02-25 19:49 (-0800), roylee17 wrote:\n\n> $ git clone --depth 1 git-full git-shallow2\n> 'git log' still gives a full history\n>\n> Why can't I clone a shallow repo from the git-full?\n> Does it requires some settings in the git-full repo?\n\nI don't know the \"why\" part but using file:// URL should work:\n\n    git clone --depth 1 file:///path/to/git-full git-shallow2\n"},{"id":"106301","messageId":"6eac7f470902252333x6326419bq305da3436cff3aa7@mail.gmail.com","threadId":"18025","inReplyTo":"87tz6hn1tg.fsf@iki.fi","subject":"Re: Does cloning a shallow repo require special setting in the cloned one?","fromName":"Roy Lee","fromEmail":"roylee17@gmail.com","sentAt":"2009-02-26T07:33:30Z","receivedAt":"2009-02-26T07:33:30Z","isPatch":false,"sender":{"key":"roylee17@gmail.com","avatar":null},"body":"On Thu, Feb 26, 2009 at 2:34 PM, Teemu Likonen <tlikonen@iki.fi> wrote:\n> On 2009-02-25 19:49 (-0800), roylee17 wrote:\n>\n>> $ git clone --depth 1 git-full git-shallow2\n>> 'git log' still gives a full history\n>>\n>> Why can't I clone a shallow repo from the git-full?\n>> Does it requires some settings in the git-full repo?\n>\n> I don't know the \"why\" part but using file:// URL should work:\n>\n>    git clone --depth 1 file:///path/to/git-full git-shallow2\n>\n\nThanks, Teemu. file:///path/to/git-full works.\n"},{"id":"106314","messageId":"20090226104657.GB4226@coredump.intra.peff.net","threadId":"18025","inReplyTo":"87tz6hn1tg.fsf@iki.fi","subject":"Re: Does cloning a shallow repo require special setting in the cloned one?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-02-26T10:46:57Z","receivedAt":"2009-02-26T10:46:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 26, 2009 at 08:34:51AM +0200, Teemu Likonen wrote:\n\n> On 2009-02-25 19:49 (-0800), roylee17 wrote:\n> \n> > $ git clone --depth 1 git-full git-shallow2\n> > 'git log' still gives a full history\n> >\n> > Why can't I clone a shallow repo from the git-full?\n> > Does it requires some settings in the git-full repo?\n> \n> I don't know the \"why\" part but using file:// URL should work:\n> \n>     git clone --depth 1 file:///path/to/git-full git-shallow2\n\nI don't think the behavior is intentional, but a side effect of the\nfact that git takes some shortcuts when cloning locally. In particular,\nit will try to copy or hardlink the object database rather than\ntransmitting over the git protocol locally. Using file:// has always\nbeen the way to suppress that shortcut.\n\nPerhaps to avoid surprise, that optimization should be turned off for\noptions which cause it to behave differently (like --depth). But I have\nto wonder what the point of --depth is locally; if you are worried about\nspace, hardlinks (the default) or alternates (\"clone -s\") are a better\nsolution.\n\n-Peff\n"},{"id":"106316","messageId":"alpine.DEB.1.00.0902261216110.6258@intel-tinevez-2-302","threadId":"18025","inReplyTo":"20090226104657.GB4226@coredump.intra.peff.net","subject":"Re: Does cloning a shallow repo require special setting in the cloned one?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-26T11:17:36Z","receivedAt":"2009-02-26T11:17:36Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 26 Feb 2009, Jeff King wrote:\n\n> On Thu, Feb 26, 2009 at 08:34:51AM +0200, Teemu Likonen wrote:\n> \n> > On 2009-02-25 19:49 (-0800), roylee17 wrote:\n> > \n> > > $ git clone --depth 1 git-full git-shallow2\n> > > 'git log' still gives a full history\n> > >\n> > > Why can't I clone a shallow repo from the git-full?\n> > > Does it requires some settings in the git-full repo?\n> > \n> > I don't know the \"why\" part but using file:// URL should work:\n> > \n> >     git clone --depth 1 file:///path/to/git-full git-shallow2\n> \n> I don't think the behavior is intentional, but a side effect of the\n> fact that git takes some shortcuts when cloning locally. In particular,\n> it will try to copy or hardlink the object database rather than\n> transmitting over the git protocol locally. Using file:// has always\n> been the way to suppress that shortcut.\n> \n> Perhaps to avoid surprise, that optimization should be turned off for\n> options which cause it to behave differently (like --depth). But I have\n> to wonder what the point of --depth is locally; if you are worried about\n> space, hardlinks (the default) or alternates (\"clone -s\") are a better\n> solution.\n\nI think it is way better to warn, since \"--depth\" is usually passed out of \nconcerns about disk space.  And --shared should shut that concern up \nrather nicely.\n\ndiff --git a/builtin-clone.c b/builtin-clone.c\nindex c338910..5831034 100644\n--- a/builtin-clone.c\n+++ b/builtin-clone.c\n@@ -511,8 +511,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \trefspec.src = src_ref_prefix;\n \trefspec.dst = branch_top.buf;\n \n-\tif (path && !is_bundle)\n+\tif (path && !is_bundle) {\n+\t\tif (option_depth)\n+\t\t\twarning(\"Ignoring --depth for local clone\");\n \t\trefs = clone_local(path, git_dir);\n+\t}\n \telse {\n \t\tstruct remote *remote = remote_get(argv[0]);\n \t\ttransport = transport_get(remote, remote->url[0]);\n\nLacks tests,\nDscho\n"},{"id":"106321","messageId":"6eac7f470902260501v6d826af7rbc5afd1df7b214a3@mail.gmail.com","threadId":"18025","inReplyTo":"20090226104657.GB4226@coredump.intra.peff.net","subject":"Re: Does cloning a shallow repo require special setting in the cloned one?","fromName":"Roy Lee","fromEmail":"roylee17@gmail.com","sentAt":"2009-02-26T13:01:34Z","receivedAt":"2009-02-26T13:01:34Z","isPatch":false,"sender":{"key":"roylee17@gmail.com","avatar":null},"body":"On Thu, Feb 26, 2009 at 6:46 PM, Jeff King <peff@peff.net> wrote:\n> On Thu, Feb 26, 2009 at 08:34:51AM +0200, Teemu Likonen wrote:\n>\n>> On 2009-02-25 19:49 (-0800), roylee17 wrote:\n>>\n>> > $ git clone --depth 1 git-full git-shallow2\n>> > 'git log' still gives a full history\n>> >\n>> > Why can't I clone a shallow repo from the git-full?\n>> > Does it requires some settings in the git-full repo?\n>>\n>> I don't know the \"why\" part but using file:// URL should work:\n>>\n>>     git clone --depth 1 file:///path/to/git-full git-shallow2\n>\n> I don't think the behavior is intentional, but a side effect of the\n> fact that git takes some shortcuts when cloning locally. In particular,\n> it will try to copy or hardlink the object database rather than\n> transmitting over the git protocol locally. Using file:// has always\n> been the way to suppress that shortcut.\n>\n> Perhaps to avoid surprise, that optimization should be turned off for\n> options which cause it to behave differently (like --depth). But I have\n> to wonder what the point of --depth is locally; if you are worried about\n> space, hardlinks (the default) or alternates (\"clone -s\") are a better\n> solution.\n>\n> -Peff\n>\n\nActully, the original intention was to find a quick way to checkout and\nbuild several projects regularly. The first thing came to me was cloning\nshallow repos for saving some time. So I tried it with my local repo first.\n\nLater, one of my co-works suggested me to try git archive, and that did\nreallly fit my needs.\n\nThanks for clarifying my confusion.\n\nRoy\n"},{"id":"106323","messageId":"20090226131946.GC7911@coredump.intra.peff.net","threadId":"18025","inReplyTo":"alpine.DEB.1.00.0902261216110.6258@intel-tinevez-2-302","subject":"Re: Does cloning a shallow repo require special setting in the cloned one?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-02-26T13:19:46Z","receivedAt":"2009-02-26T13:19:46Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 26, 2009 at 12:17:36PM +0100, Johannes Schindelin wrote:\n\n> I think it is way better to warn, since \"--depth\" is usually passed out of \n> concerns about disk space.  And --shared should shut that concern up \n> rather nicely.\n> \n> diff --git a/builtin-clone.c b/builtin-clone.c\n> index c338910..5831034 100644\n> --- a/builtin-clone.c\n> +++ b/builtin-clone.c\n> @@ -511,8 +511,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n>  \trefspec.src = src_ref_prefix;\n>  \trefspec.dst = branch_top.buf;\n>  \n> -\tif (path && !is_bundle)\n> +\tif (path && !is_bundle) {\n> +\t\tif (option_depth)\n> +\t\t\twarning(\"Ignoring --depth for local clone\");\n>  \t\trefs = clone_local(path, git_dir);\n> +\t}\n>  \telse {\n>  \t\tstruct remote *remote = remote_get(argv[0]);\n>  \t\ttransport = transport_get(remote, remote->url[0]);\n\nThat seems reasonable to me.\n\n-Peff\n"},{"id":"106385","messageId":"m3prh4vhdg.fsf@localhost.localdomain","threadId":"18025","inReplyTo":"6eac7f470902260501v6d826af7rbc5afd1df7b214a3@mail.gmail.com","subject":"Re: Does cloning a shallow repo require special setting in the cloned one?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-02-27T00:42:22Z","receivedAt":"2009-02-27T00:42:22Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Roy Lee <roylee17@gmail.com> writes:\n> On Thu, Feb 26, 2009 at 6:46 PM, Jeff King <peff@peff.net> wrote:\n>> On Thu, Feb 26, 2009 at 08:34:51AM +0200, Teemu Likonen wrote:\n>>> On 2009-02-25 19:49 (-0800), roylee17 wrote:\n>>>\n>>>> $ git clone --depth 1 git-full git-shallow2\n>>>> 'git log' still gives a full history\n>>>>\n>>>> Why can't I clone a shallow repo from the git-full?\n>>>> Does it requires some settings in the git-full repo?\n>>>\n>>> I don't know the \"why\" part but using file:// URL should work:\n>>>\n>>>     git clone --depth 1 file:///path/to/git-full git-shallow2\n>>\n>> I don't think the behavior is intentional, but a side effect of the\n>> fact that git takes some shortcuts when cloning locally. In particular,\n>> it will try to copy or hardlink the object database rather than\n>> transmitting over the git protocol locally. Using file:// has always\n>> been the way to suppress that shortcut.\n>>\n>> Perhaps to avoid surprise, that optimization should be turned off for\n>> options which cause it to behave differently (like --depth). But I have\n>> to wonder what the point of --depth is locally; if you are worried about\n>> space, hardlinks (the default) or alternates (\"clone -s\") are a better\n>> solution.\n> \n> Actully, the original intention was to find a quick way to checkout and\n> build several projects regularly. The first thing came to me was cloning\n> shallow repos for saving some time. So I tried it with my local repo first.\n> \n> Later, one of my co-works suggested me to try git archive, and that did\n> reallly fit my needs.\n\nPerhaps you would be interested then in contrib/workdir/git-new-workdir\nscript then, which allows for multiple checked out copies from a single\nrepository?  Be aware that if you work in those copies, and are not\ncareful, it can lead to confusion; but if all but one of checkouts are\nread only it could be the best solution.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}