Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shallow Clone #2782

Closed
antis81 opened this issue Dec 25, 2014 · 4 comments
Closed

Shallow Clone #2782

antis81 opened this issue Dec 25, 2014 · 4 comments

Comments

@antis81
Copy link

antis81 commented Dec 25, 2014

As discussed in issue #1142, shallow clones are not supported yet by the libgit2 clone API.

One can work around this by initializing a repository, setting the core.depth variable in the config, setup a remote etc. But ... it does not work with git_clone().

IMHO the git_clone_options struct should be extended by an unsigned int depth variable, which in turn is given to git_clone() to setup the --depth config variable.

Also referencing issue #1430 - just for the record.

Thanks for all the support this far and merry christmas to y'all.

EDIT: The remote alias "origin" is also set in create_and_configure_origin(). This should be an option as well.

How about adding a git_remote *remote member in git_clone_options, that would allow to manually setup a customized remote?

@carlosmn
Copy link
Member

As discussed in issue #1142, shallow clones are not supported yet by the libgit2 clone API.

Shallow clones aren't supported by libgit2. This is not a missing option, it's missing the feature completely. We cannot expose this option because we do not support it.

As #1430 points out, we do not support shallow repositories. Even if we added this feature to the network request, we still wouldn't be able to work with the resulting repository.

How about adding a git_remote *remote member in git_clone_options, that would allow to manually setup a customized remote?

This would not work, as the remote needs to be created on the repository, which does not exist when the user calls for a clone. We do provide a way to completely customise the repository via a factory callback. The user can set whatever options they wish on the remote before handing it to the clone process.

@antis81
Copy link
Author

antis81 commented Dec 28, 2014

... We do provide a way to completely customise the repository via a factory callback. The user can set whatever options they wish on the remote before handing it to the clone process.

Ah thanks! I totally overlooked that (a little hint in the git_clone docs wouldn't hurt anyways). Of course, this will help with a "renamed origin alias" and other issues as well.

I'll happily wait, until shallow clones are fully supported (including submodules).

@heavensrevenge
Copy link

The https://github.com/creationix/jsgit tool which uses https://github.com/creationix/js-git as a backend while using node v0.11.5 http://nodejs.org/dist/v0.11.5/ acually does a shallow copy clone of a git repository via creationix/js-git@ccca651a65da82a6ac0a8b01e9e2cecb0c76cd91and creationix/js-git@14b5f0d .
Newer versions of node don't seem to allow the command to succeed and you need to call the command like jsgit-fetch --depth 5 git://github.com/creationix/jsgit.git

It's the only git "reimplementation" I've found which actually succeeds in a shallow clone from a very simple implementation so maybe you can use it as an example to add the capability in libgit2 as I'm interested in rust-lang/cargo#1171 benefitting from how amazingly useful a shallow clone could be for build purposes.

#1142 to refrence since it may be the origional request for shallow clones.

@carlosmn
Copy link
Member

#3058 lists what we would need to support/do and is the issue where any discussion on it should happen, rather than an issue asking for the non-existent feature to be exposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants