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

Optional use of shallow clone for git repos #1888

Closed
NickAb opened this issue Dec 30, 2015 · 8 comments
Closed

Optional use of shallow clone for git repos #1888

NickAb opened this issue Dec 30, 2015 · 8 comments
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code

Comments

@NickAb
Copy link

NickAb commented Dec 30, 2015

It would be great if there was an option to enable shallow clone for repositories. If set, then RtD should use shallow clone (--depth 1 option of git clone) instead of full clone if possible.
This will result in huge disk space saving for projects with large history.

E.g., for one of our projects /www/readthedocs.org/user_builds/{project}/checkouts/latest folder takes up to 400 Mb, when cloned with --depth 1, it takes up only 12 Mb.

@NickAb NickAb changed the title Use shallow clone for git Optionsl use of shallow clone for git repos Dec 30, 2015
@NickAb NickAb changed the title Optionsl use of shallow clone for git repos Optional use of shallow clone for git repos Dec 30, 2015
@agjohnson
Copy link
Contributor

This would definitely be worth looking into, this might be able to take a chunk of storage. I haven't looked into this at all, be the --depth option would need to be supported by git fetch, as we don't actually run a git clone except on initial import, afaik.

@agjohnson agjohnson added the Improvement Minor improvement to code label Dec 31, 2015
@ericholscher
Copy link
Member

Looks like we can now support this with the --no-single-branch option on git clone. There doesn't appear to be a similar option for git fetch, though, so we might not be able to reliably update the list of branches while keeping a shallow clone on disk.

@ericholscher
Copy link
Member

If someone could test that this is possible, it would be a pretty sizable win in terms of disk space needed.

@NickAb
Copy link
Author

NickAb commented Jan 9, 2016

What exactly do you mean by update the list of branches?

If it is simple obtaining a list of all branches and tags, then it can be done using git ls-remote command.

git ls-remote --heads --tags https://github.com/rtfd/readthedocs.org.git

You don't even need to clone repository to do so.

See https://www.kernel.org/pub/software/scm/git/docs/git-ls-remote.html

@ericholscher
Copy link
Member

travis uses --depth=50

@agjohnson agjohnson added the Accepted Accepted issue on our roadmap label Sep 19, 2018
@agjohnson agjohnson added this to the Build stability milestone Sep 19, 2018
@stsewd
Copy link
Member

stsewd commented Nov 29, 2018

We have the depth option in the fetch command too https://git-scm.com/docs/git-fetch/2.17.0#git-fetch---depthltdepthgt, I'm testing it, looks like is something that could work for every project. Any reason to not do that on every project? Also, depth=1 looks fine.

@ericholscher
Copy link
Member

Do we still get branch/tag info with a shallow clone?

@stsewd
Copy link
Member

stsewd commented Nov 29, 2018

Yeah, we do, actually I just have a POC for this. So, we could add a feature flag to test and force everyone to do a shallow clone, or make it an option for the users. The only thing I can see is where a custom extension needs info from other commits I guess?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Improvement Minor improvement to code
Projects
None yet
Development

No branches or pull requests

4 participants