rugged icon indicating copy to clipboard operation
rugged copied to clipboard

Ability to pass options to clone?

Open benbalter opened this issue 12 years ago • 6 comments

Wondering if it's possible to pass options to the clone action, specifically --recursive and --depth=1

Here's what I've got:

repo = Rugged::Repository.clone_at @git_url, @source, { :branch => @git_ref, :recursive => true, :depth => 1 }

benbalter avatar Dec 02 '13 23:12 benbalter

@benbalter Currently, the underlying libgit2 code doesn't support making shallow clones nor does it support recursive submodule updates. Using the submodule APIs, it would probably be possible to implement the equivalent of --recursive but I don't think the necessary APIs are currently available in Rugged. I'm pretty sure there is no way to do a shallow clone at all without changes to the libgit2.

arrbee avatar Dec 02 '13 23:12 arrbee

Le sad. Thanks for the prompt response.

benbalter avatar Dec 03 '13 00:12 benbalter

Shallow fetches/clones are a mess and still a hack. There is currently an attempt at making them better-defined, but the odd repos that result are a mess and still have many limitations even with git-core.

While not as fast to type, you do have a programming language available, which makes automatic recursive submodule initialisation less of an advantage. It's probably enough of a promiment git-core feature that it will have to be implemented at some point.

carlosmn avatar Dec 03 '13 00:12 carlosmn

Thanks for clarifying @carlosmn - you're right (as always). I do have it on my TODO list to add recursive submodule support to libgit2 checkout and clone, but it hasn't been too high up there. Still, probably a good thing to get to and not too hard, I think.

arrbee avatar Dec 03 '13 00:12 arrbee

Better shallow-repo support is on my list, but the concepts are tangled up with alternates and grafts, and it could get a little hairy.

ben avatar Dec 03 '13 03:12 ben

FWIW, related libgit2 issue is https://github.com/libgit2/libgit2/issues/3058

dideler avatar Feb 17 '16 14:02 dideler

libgit2 added shallow support in version 1.7.0 (July 2023)

kjetilho avatar Dec 27 '23 14:12 kjetilho

libgit2 added shallow support in version 1.7.0 (July 2023)

Thanks for updating this ancient issue. Marking as resolved.

benbalter avatar Dec 28 '23 16:12 benbalter

libgit2 added shallow support in version 1.7.0 (July 2023)

Thanks for updating this ancient issue. Marking as resolved.

hmm, but I don't see how Rugged allows me to pass a value for depth to fetch?

kjetilho avatar Dec 28 '23 18:12 kjetilho