Added a compiled wrapper to replace the git.cmd script.
[msysgit.git] / cmd / git.cmd
blobe697a232f6cf060ab86ee45e01b7d96aac1381a8
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
13 @if not defined TERM set TERM=msys
15 @if "%1"=="gui" @goto gui
17 :default
18 @rem Get the current console ("OEM") codepage.
19 @for /f %%i in ('getcp -oem') do @set cp_oem=%%i
20 @rem Get the current GUI ("ANSI") codepage.
21 @for /f %%i in ('getcp -ansi') do @set cp_ansi=%%i
22 @rem Set the console codepage to match the GUI codepage.
23 @chcp %cp_ansi% > nul < nul
24 @git.exe %*
25 @set ErrorLevel=%ErrorLevel%
26 @rem Restore the original console codepage.
27 @chcp %cp_oem% > nul < nul
28 @goto quit
30 :gui
31 @if "%2"=="citool" @goto default
32 @for /f "tokens=1-1*" %%a in ("%*") do @set args=%%b
33 @start "git-gui" wish.exe "%git_install_root%\libexec\git-core\git-gui" -- %args%
35 :quit
36 @"%COMSPEC%" /c exit /b %ErrorLevel%