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

Clone arguments --depth 1 not working with lg.callMain(['clone', url, dir, '--depth', '1']) #52

Closed
tiagobento opened this issue Sep 6, 2022 · 6 comments

Comments

@tiagobento
Copy link

Currently trying to experiment the performance of wasm-git for not-so-small Git repositories, but using --depth 1 on a clone call doesn't seem to have any effect. Any idea what could be happening?

What I did was I modified the githttpserver to not add an Authorization header to HTTP requests and used Isomorphic Git's CORS proxy to bypass CORS restrictions to GitHub. So from my localhost, I try to download any fairly-sized GitHub repository, and it takes forever, even with --depth 1.

Let me know if I can help fixing this!

@tiagobento
Copy link
Author

tiagobento commented Sep 12, 2022

Looks like I had some reading to do before opening this issue :)

Just found that lg.callMain is actually deferring to examples/lg2.c's main, which then calls libgit2's clone function. Also, shallow clones are not supported by libgit2 (as per libgit2/libgit2#3058), so closing this issue.

@petersalomonsen
Copy link
Owner

sorry for not seeing this before now, but thanks for going into the depths of this. I wasn't aware of the missing support for shallow clones myself.

@DanilKazanov
Copy link

DanilKazanov commented Aug 15, 2023

Shallow clone is now supported in libgit2 =)

And btw, is there any solution to clone with --single-branch option?

@petersalomonsen
Copy link
Owner

wasm-git is now up to date with the latest libgit2

@DanilKazanov
Copy link

DanilKazanov commented Aug 22, 2023

wasm-git is now up to date with the latest libgit2

Where I can see api docs? I tried to use lg.callMain(["clone", url, dir, "--depth", "1"]), and it looks like it's not working.

@petersalomonsen
Copy link
Owner

at this point wasm-git expose the examples from libgit2, and then you need to modify this file here: https://github.com/libgit2/libgit2/blob/main/examples/clone.c so that it can accept the depth argument ( or just set the clone_opts.fetch_opts.depth property directly to what you want ).

however there's also a new cli in libgit2 that I would like to add support for and it seems it also does handle depth:

https://github.com/libgit2/libgit2/blob/main/src/cli/cmd_clone.c

CLI support is on my todo list.

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