From b62de00276e18445a61470dfbf2c5f4468a78fb1 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Mon, 16 Aug 2021 10:00:54 -0700 Subject: [PATCH] Prevent wildcard expansion in git sparse checkout add (#2745) Co-authored-by: Ben Broderick Phillips --- eng/common/pipelines/templates/steps/sparse-checkout.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/common/pipelines/templates/steps/sparse-checkout.yml b/eng/common/pipelines/templates/steps/sparse-checkout.yml index 50603bc35..5b36bf48e 100644 --- a/eng/common/pipelines/templates/steps/sparse-checkout.yml +++ b/eng/common/pipelines/templates/steps/sparse-checkout.yml @@ -25,8 +25,6 @@ steps: script: | function SparseCheckout([Array]$paths, [Hashtable]$repository) { - $paths = $paths -Join ' ' - $dir = $repository.WorkingDirectory if (!$dir) { $dir = "./$($repository.Name)" @@ -50,7 +48,9 @@ steps: git sparse-checkout set '/*' '!/*/' '/eng' } - $gitsparsecmd = "git sparse-checkout add $paths" + # Prevent wildcard expansion in Invoke-Expression (e.g. for checkout path '/*') + $quotedPaths = $paths | ForEach-Object { "'$_'" } + $gitsparsecmd = "git sparse-checkout add $quotedPaths" Write-Host $gitsparsecmd Invoke-Expression -Command $gitsparsecmd