Skip to content

Commit

Permalink
Properly escape GitExe and CygPathExe for WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
socram8888 committed Nov 7, 2022
1 parent f0ac7b8 commit 871d36e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/GitInfo/build/GitInfo.targets
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
</PropertyGroup>

<!-- Account for cygwin/WSL separately -->
<Exec Command='"$(CygPathExe)" -w "$(_GitOutput)"'
<Exec Command='$(CygPathExe) -w "$(_GitOutput)"'
EchoOff='true'
WorkingDirectory="$(GitInfoBaseDir)"
StandardErrorImportance='high'
Expand Down Expand Up @@ -297,7 +297,7 @@
</Exec>

<!-- Account for cygwin/WSL separately -->
<Exec Command='"$(CygPathExe)" -w "$(_GitCommonDir)"'
<Exec Command='$(CygPathExe) -w "$(_GitCommonDir)"'
EchoOff='true'
WorkingDirectory="$(GitInfoBaseDir)"
StandardErrorImportance='high'
Expand Down Expand Up @@ -588,7 +588,7 @@
<Message Text="Using base version from version file $(GitVersionFile)'" Importance="normal" />

<!-- Account for cygwin/WSL separately -->
<Exec Command='"$(CygPathExe)" -u "$(_GitVersionFile)"'
<Exec Command='$(CygPathExe) -u "$(_GitVersionFile)"'
EchoOff='true'
WorkingDirectory="$(GitRoot)"
StandardErrorImportance='high'
Expand Down Expand Up @@ -630,7 +630,7 @@
</PropertyGroup>

<!-- Account for cygwin/WSL separately -->
<Exec Command='"$(CygPathExe)" -u $(_GitCommitsRelativeTo)'
<Exec Command='$(CygPathExe) -u $(_GitCommitsRelativeTo)'
EchoOff='true'
WorkingDirectory="$(GitRoot)"
StandardErrorImportance='high'
Expand Down Expand Up @@ -1092,7 +1092,7 @@

<!-- If we didn't find it in the PATH nor the above locations, check for git installed in WSL -->
<Exec Condition="'$(GitExe)' == ''"
Command="$(MSBuildThisFileDirectory)wslrun.cmd git --version"
Command='"$(MSBuildThisFileDirectory)wslrun.cmd" git --version'
EchoOff='true'
ContinueOnError='true'
StandardErrorImportance='high'
Expand All @@ -1101,8 +1101,8 @@
<Output TaskParameter="ExitCode" PropertyName="MSBuildLastExitCode" />
</Exec>
<PropertyGroup Condition="'$(GitExe)' == '' And '$(MSBuildLastExitCode)' == '0'">
<GitExe>$(MSBuildThisFileDirectory)wslrun.cmd git</GitExe>
<CygPathExe>$(MSBuildThisFileDirectory)wslpath.cmd</CygPathExe>
<GitExe>"$(MSBuildThisFileDirectory)wslrun.cmd" git</GitExe>
<CygPathExe>"$(MSBuildThisFileDirectory)wslpath.cmd"</CygPathExe>
</PropertyGroup>

<PropertyGroup Condition="'$(GitExe)' == ''">
Expand Down
4 changes: 2 additions & 2 deletions src/GitInfo/build/wslpath.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ if "%1" == "-u" shift /1
REM Convert path to Linux
if exist "%1\*" (pushd %1) else (pushd %~dp1)
if ERRORLEVEL 1 goto :eof
%WSLRUN% pwd
"%WSLRUN%" pwd
popd
goto :eof

:towindows
REM Convert path to Windows
%WSLRUN% cd "'%2'" ^&^& cmd.exe /c cd
"%WSLRUN%" cd "'%2'" ^&^& cmd.exe /c cd

0 comments on commit 871d36e

Please sign in to comment.