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

[Feature request] Use git worktrees instead of individual clones in cache #492

Open
touraill-adobe opened this issue Jul 28, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@touraill-adobe
Copy link

When using CPM_SOURCE_CACHE, each dependency is cloned in its own folder even if they are just different commits of the same repo. It seems to me that using git worktree would greatly optimize the download time and storage usage, by cloning a remote repo only once.

The behavior I would expect would be to have one folder in the cache per repo url, that contains a bare repo, then the usual hashed folders with worktrees created from this repo.

What do you think?

@TheLartians
Copy link
Member

That's a pretty cool git feature I wasn't aware of! I agree it would make a lot of sense for CPM to use this feature.

@TheLartians TheLartians added the enhancement New feature or request label Aug 19, 2023
@touraill-adobe
Copy link
Author

Today I learned about git clone --reference-if-able, which may be a simpler alternative to worktrees in the context of CPM. It allows retrieving git objects from an existing local clone, to avoid downloading them from the remote server. clone times are dramatically reduced (like a factor of 10 or more, depending on your network). If you want to be safe you can add --dissociate to not borrow the objects from the local reference but copy them, which is a little longer but still saves a lot of time by avoiding some download.

I'm not sure what flexibility you have in CPM w.r.t. git commands but if you can inject custom arguments, and if you can easily find a previous clone of a repo in the CPM cache, then I think this optimization would be worth investigating.

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

No branches or pull requests

2 participants