From c846b4e5e694e6243fac03a10ad76c5350aecdd7 Mon Sep 17 00:00:00 2001 From: Timothy Sutton Date: Mon, 24 Nov 2025 11:44:57 -0500 Subject: [PATCH 1/4] Ignore Gemfile.lock --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1de17f9..590fd39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *:lock *.gem +Gemfile.lock From d59801d97eee6dc7ea4bfd4480028952d852110e Mon Sep 17 00:00:00 2001 From: Timothy Sutton Date: Wed, 26 Nov 2025 15:45:14 -0500 Subject: [PATCH 2/4] Fix slow sparse-clone by adding back --shared flag --- lib/git-fastclone.rb | 2 +- spec/git_fastclone_runner_spec.rb | 41 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/lib/git-fastclone.rb b/lib/git-fastclone.rb index 876f53a..441e633 100644 --- a/lib/git-fastclone.rb +++ b/lib/git-fastclone.rb @@ -255,7 +255,7 @@ def clone(url, rev, src_dir, config) # For sparse checkouts, clone directly from the local mirror and skip the actual checkout process # For normal clones, use --reference and clone from the remote URL if sparse_paths - clone_commands.push('--no-checkout') + clone_commands.push('--no-checkout', '--shared') clone_commands << mirror.to_s << clone_dest else clone_commands << '--reference' << mirror.to_s << url.to_s << clone_dest diff --git a/spec/git_fastclone_runner_spec.rb b/spec/git_fastclone_runner_spec.rb index 4bbc641..d8baf4d 100644 --- a/spec/git_fastclone_runner_spec.rb +++ b/spec/git_fastclone_runner_spec.rb @@ -145,6 +145,47 @@ def create_lockfile_double end end + context 'with sparse checkout' do + before(:each) do + subject.sparse_paths = %w[path1 path2] + end + + it 'should clone with --no-checkout and --shared flags' do + expect(subject).to receive(:fail_on_error).with( + 'git', 'clone', '--quiet', '--no-checkout', '--shared', '/cache', '/pwd/.', + { quiet: true, print_on_failure: false } + ) { runner_execution_double } + expect(subject).to receive(:perform_sparse_checkout).with('/pwd/.', 'PH') + + subject.clone(placeholder_arg, 'PH', '.', nil) + end + + 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/.', + { quiet: false, print_on_failure: false } + ) { runner_execution_double } + expect(subject).to receive(:perform_sparse_checkout).with('/pwd/.', 'PH') + + subject.clone(placeholder_arg, 'PH', '.', nil) + end + + it 'should not perform regular checkout when sparse checkout is enabled' do + expect(subject).to receive(:fail_on_error).with( + 'git', 'clone', '--quiet', '--no-checkout', '--shared', '/cache', '/pwd/.', + { quiet: true, print_on_failure: false } + ) { runner_execution_double } + expect(subject).to receive(:perform_sparse_checkout).with('/pwd/.', 'PH') + expect(subject).not_to receive(:fail_on_error).with( + 'git', 'checkout', '--quiet', 'PH', + anything + ) + + subject.clone(placeholder_arg, 'PH', '.', nil) + end + end + context 'with pre-clone-hook' do let(:pre_clone_hook) { '/some/command' } before(:each) do From faf29ea6c76c87a28fda9ea846bb4aafde79d8fb Mon Sep 17 00:00:00 2001 From: Timothy Sutton Date: Wed, 26 Nov 2025 15:45:57 -0500 Subject: [PATCH 3/4] Bump version to 1.6.1 --- lib/git-fastclone/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git-fastclone/version.rb b/lib/git-fastclone/version.rb index eaba986..99c539c 100644 --- a/lib/git-fastclone/version.rb +++ b/lib/git-fastclone/version.rb @@ -2,5 +2,5 @@ # Version string for git-fastclone module GitFastCloneVersion - VERSION = '1.6.0' + VERSION = '1.6.1' end From 4e04bf13e38a9beac7557b7779c28cae9f43c5d2 Mon Sep 17 00:00:00 2001 From: Timothy Sutton Date: Wed, 26 Nov 2025 16:40:29 -0500 Subject: [PATCH 4/4] Add comment about --shared --- lib/git-fastclone.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/git-fastclone.rb b/lib/git-fastclone.rb index 441e633..d55b2e5 100644 --- a/lib/git-fastclone.rb +++ b/lib/git-fastclone.rb @@ -253,6 +253,8 @@ def clone(url, rev, src_dir, config) 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 + # live on different filesystem volumes. # For normal clones, use --reference and clone from the remote URL if sparse_paths clone_commands.push('--no-checkout', '--shared')