Avoid quoting environment variable values.
[msysgit.git] / cmd / git.cmd
blobdcd92b41e05a45ddcf8cf620335fc17fc4e58b91
1 @rem Do not use "echo off" to not affect any child calls.
2 @setlocal
4 @rem Get the abolute path to the parent directory, which is assumed to be the
5 @rem Git installation root.
6 @for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
7 @set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH%
9 @if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
10 @if not exist "%HOME%" @set HOME=%USERPROFILE%
12 @set PLINK_PROTOCOL=ssh
14 @if "%1"=="gui" @goto gui
16 :default
17 @rem Get the current console ("OEM") codepage.
18 @for /f %%i in ('getcp -oem') do @set cp_oem=%%i
19 @rem Get the current GUI ("ANSI") codepage.
20 @for /f %%i in ('getcp -ansi') do @set cp_ansi=%%i
21 @rem Set the console codepage to match the GUI codepage.
22 @chcp %cp_ansi% > nul < nul
23 @git.exe %*
24 @set ErrorLevel=%ErrorLevel%
25 @rem Restore the original console codepage.
26 @chcp %cp_oem% > nul < nul
27 @goto quit
29 :gui
30 @if "%2"=="citool" @goto default
31 @for /f "tokens=1-1*" %%a in ("%*") do @set args=%%b
32 @start "git-gui" wish.exe "%git_install_root%\libexec\git-core\git-gui" -- %args%
34 :quit
35 @"%COMSPEC%" /c exit /b %ErrorLevel%