From d69812732709a09957d4f363a997bf1bb5ebc8d7 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Fri, 13 Aug 2021 13:44:21 -0400 Subject: [PATCH] Prevent wildcard expansion in git sparse checkout add --- 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 50603bc35a24..5b36bf48e4a9 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