From d2b17e29effebd03612ec1758b806a567fbecb91 Mon Sep 17 00:00:00 2001 From: Harry Marr Date: Sat, 10 Jun 2023 14:31:46 -0400 Subject: [PATCH] Check `only_path` is present before modifying it --- Library/Homebrew/download_strategy.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index a96bd2bbdd..3a3fcddcb2 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -835,9 +835,11 @@ class GitDownloadStrategy < VCSDownloadStrategy # constructor calls `cache_tag` and sets the cache path. @only_path = meta[:only_path] - # "Cone" mode of sparse checkout requires patterns to be directories - @only_path = "/#{@only_path}" unless @only_path.start_with?("/") - @only_path = "#{@only_path}/" unless @only_path.end_with?("/") + if @only_path.present? + # "Cone" mode of sparse checkout requires patterns to be directories + @only_path = "/#{@only_path}" unless @only_path.start_with?("/") + @only_path = "#{@only_path}/" unless @only_path.end_with?("/") + end super @ref_type ||= :branch