Skip to content

Commit

Permalink
Prevent wildcard expansion in git sparse checkout add (#15286)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Broderick Phillips <[email protected]>
  • Loading branch information
azure-sdk and benbp authored Aug 16, 2021
1 parent 3a6d402 commit 2f77ce5
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 2f77ce5

Please sign in to comment.