From 2cd207618688f247c28378386e88fc23945c100d Mon Sep 17 00:00:00 2001 From: Harry Marr Date: Fri, 9 Jun 2023 22:58:00 -0400 Subject: [PATCH] Use "cone" mode for sparse checkouts --- Library/Homebrew/download_strategy.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 8a0edae687..04d8b95883 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -1075,9 +1075,17 @@ class GitDownloadStrategy < VCSDownloadStrategy command! "git", args: ["config", "core.sparseCheckout", "true"], chdir: cached_location + command! "git", + args: ["config", "core.sparseCheckoutCone", "true"], + chdir: cached_location (git_dir/"info").mkpath - (git_dir/"info"/"sparse-checkout").atomic_write("#{@only_path}\n") + + # "Cone" mode of sparse checkout requires patterns to be directories + path = @only_path + path = "/#{path}" unless path.start_with?("/") + path = "#{path}/" unless path.end_with?("/") + (git_dir/"info"/"sparse-checkout").atomic_write("#{path}\n") end end