Skip to content

Commit

Permalink
Prevent wildcard expansion in git sparse checkout add (#23325)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
  • Loading branch information
azure-sdk and benbp authored Aug 16, 2021
1 parent 07ac326 commit 33f778d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eng/common/pipelines/templates/steps/sparse-checkout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ steps:
script: |
function SparseCheckout([Array]$paths, [Hashtable]$repository)
{
$paths = $paths -Join ' '
$dir = $repository.WorkingDirectory
if (!$dir) {
$dir = "./$($repository.Name)"
Expand All @@ -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
Expand Down

0 comments on commit 33f778d

Please sign in to comment.