commercialhaskell/pantry

Pantry.Repo.archiveSubmodules does not respect variable expansion on PowerShell

Closed this issue · 2 comments

Motivation and discussion: commercialhaskell/stack#5536

The problem is that $displaypath is expanded prematurely (before it has a value) on PowerShell because https://hackage.haskell.org/package/process-1.6.18.0/src/System/Process/Windows.hsc translateInternal encloses all arguments in double quotes (extract):

    Gnu -> runGitCommand
      [ "submodule"
      , "foreach"
      , "--recursive"
      , "git -c core.autocrlf=false archive --prefix=$displaypath/ -o bar.tar HEAD; "
        <> "tar" <> forceLocal <> " -Af " <> tarball <> " bar.tar"
      ]

The proposed solution is to use (or the closest to it, with BSD tar):

git ls-files --recurse-submodules | tar <force-local> -caf <tarball> --verbatim-files-from -T-

@jship, I have run into a problem with this proposed solution. git archive preserves the attributes of the files in the repository. It knows, for example, that test-inject.sh is marked as executable. git clone followed by tar does not preserve that attribute. That is reflected in the failing unit test on Windows.

@jship, I am going to revert to a solution that detects if variable expansion is occurring and then escapes the command in git submodule foreach if it is.