-
Notifications
You must be signed in to change notification settings - Fork 29
Add --shared flag when using sparse checkout
#78
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
Conversation
| @@ -1,2 +1,3 @@ | |||
| *:lock | |||
| *.gem | |||
| Gemfile.lock | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated but we no longer need to track changes to this file since we removed it from Git
--shared flag when using sparse checkout
|
|
||
| clone_commands = ['git', 'clone', verbose ? '--verbose' : '--quiet'] | ||
| # For sparse checkouts, clone directly from the local mirror and skip the actual checkout process | ||
| # --shared is included so that the checkout remains fast even if the reference and destination directories |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc says this is a dangerous option which totally makes sense: https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---shared
just to be suare that we have tested cases like deleting the checkout in the machine? yeah this is def only for CI usage only since we have clear idea on when and how to use these clones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. That's why initially I removed it in between the 1.6.0.pre1 -> 1.6.0 release because I wasn't going to keep it if it wasn't improving the checkout speed. But yeah, that's where when I tested locally on my Mac it wasn't the same situation as the disk/volume setup on the CI workers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's potentially room to support more flags to augment or change the behavior of the sparse checkout, but I figure we should only add those if we've got a good reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100%, we should not allow caller to pass in any flags
| it 'should clone with verbose mode and --shared flag' do | ||
| subject.verbose = true | ||
| expect(subject).to receive(:fail_on_error).with( | ||
| 'git', 'clone', '--verbose', '--no-checkout', '--shared', '/cache', '/pwd/.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder with these new flags if the specs should include inspecting the cloned repo... for example we expect .git/objects/info/alternates to exists with --shared and not the case without --shared?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah – this work made me think that this repo could benefit from some simple integration tests which actually clones some simple repos and asserts for the expected state of the cloned repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be easy to write with AI
In an earlier test of the
--sparse-pathsfeature I had kept the--sharedflag to be used for the sparse checkout, but removed it because when testing on my local Mac it didn't seem to improve the speed.But, using
--sharedgreatly improves speed on systems where the reference Git clone is not the same as the destination checkout directory.--sharedcreates an "alternates" file at.git/objects/info/alternatesthat just contains a path that points back to the original reference repo location.Without
--shared, if Git can't use a shallow copy mechanism, it will make a full copy of the entire.gitdirectory contents from the reference clone, potentially taking minutes for a very large repo.