Re: Does cloning a shallow repo require special setting in the cloned one?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Thu, 26 Feb 2009, Jeff King wrote:

> On Thu, Feb 26, 2009 at 08:34:51AM +0200, Teemu Likonen wrote:
> 
> > On 2009-02-25 19:49 (-0800), roylee17 wrote:
> > 
> > > $ git clone --depth 1 git-full git-shallow2
> > > 'git log' still gives a full history
> > >
> > > Why can't I clone a shallow repo from the git-full?
> > > Does it requires some settings in the git-full repo?
> > 
> > I don't know the "why" part but using file:// URL should work:
> > 
> >     git clone --depth 1 file:///path/to/git-full git-shallow2
> 
> I don't think the behavior is intentional, but a side effect of the
> fact that git takes some shortcuts when cloning locally. In particular,
> it will try to copy or hardlink the object database rather than
> transmitting over the git protocol locally. Using file:// has always
> been the way to suppress that shortcut.
> 
> Perhaps to avoid surprise, that optimization should be turned off for
> options which cause it to behave differently (like --depth). But I have
> to wonder what the point of --depth is locally; if you are worried about
> space, hardlinks (the default) or alternates ("clone -s") are a better
> solution.

I think it is way better to warn, since "--depth" is usually passed out of 
concerns about disk space.  And --shared should shut that concern up 
rather nicely.

diff --git a/builtin-clone.c b/builtin-clone.c
index c338910..5831034 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -511,8 +511,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 	refspec.src = src_ref_prefix;
 	refspec.dst = branch_top.buf;
 
-	if (path && !is_bundle)
+	if (path && !is_bundle) {
+		if (option_depth)
+			warning("Ignoring --depth for local clone");
 		refs = clone_local(path, git_dir);
+	}
 	else {
 		struct remote *remote = remote_get(argv[0]);
 		transport = transport_get(remote, remote->url[0]);

Lacks tests,
Dscho

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux