Merge pull request #2430 from qfp64/faster-init

Improve init speed
This commit is contained in:
Dax T Games
2020-12-11 05:48:07 -05:00
committed by GitHub
5 changed files with 60 additions and 55 deletions

48
vendor/init.bat vendored
View File

@ -67,7 +67,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
set "max_depth=%~2"
shift
) else (
%lib_console% show_error "'/max_depth' requires a number between 1 and 5!"
%print_error% "'/max_depth' requires a number between 1 and 5!"
exit /b
)
) else if /i "%1" == "/c" (
@ -88,7 +88,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
set "GIT_INSTALL_ROOT=%~2"
shift
) else (
%lib_console% show_error "The Git install root folder "%~2", you specified does not exist!"
%print_error% "The Git install root folder "%~2", you specified does not exist!"
exit /b
)
) else if /i "%1"=="/nix_tools" (
@ -110,7 +110,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
set "HOME=%~2"
shift
) else (
%lib_console% show_error The home folder "%2", you specified does not exist!
%print_error% The home folder "%2", you specified does not exist!
exit /b
)
) else if /i "%1" == "/svn_ssh" (
@ -125,11 +125,11 @@ goto var_loop
:start
:: Sets CMDER_SHELL, CMDER_CLINK, CMDER_ALIASES
%lib_base% cmder_shell
%lib_console% debug_output init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%"
%lib_console% debug_output init.bat "Env Var - debug_output=%debug_output%"
%print_debug% init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%"
%print_debug% init.bat "Env Var - debug_output=%debug_output%"
if defined CMDER_USER_CONFIG (
%lib_console% debug_output init.bat "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '%CMDER_USER_CONFIG%'!"
%print_debug% init.bat "CMDER IS ALSO USING INDIVIDUAL USER CONFIG FROM '%CMDER_USER_CONFIG%'!"
if not exist "%CMDER_USER_CONFIG%\opt" md "%CMDER_USER_CONFIG%\opt"
)
@ -144,7 +144,7 @@ if "%PROCESSOR_ARCHITECTURE%"=="x86" (
)
if "%CMDER_CLINK%" == "1" (
%lib_console% verbose_output "Injecting Clink!"
%print_verbose% "Injecting Clink!"
:: Run clink
if defined CMDER_USER_CONFIG (
@ -163,15 +163,15 @@ if "%CMDER_CLINK%" == "1" (
"%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor"
)
) else (
%lib_console% verbose_output "WARNING: Incompatible 'ComSpec/Shell' Detetected Skipping Clink Injection!"
%print_verbose% "WARNING: Incompatible 'ComSpec/Shell' Detetected Skipping Clink Injection!"
)
if "%CMDER_CONFIGURED%" GTR "1" (
%lib_console% verbose_output "Cmder is already configured, skipping Cmder Init!"
%print_verbose% "Cmder is already configured, skipping Cmder Init!"
goto USER_ALIASES
) else if "%CMDER_CONFIGURED%" == "1" (
%lib_console% verbose_output "Cmder is already configured, skipping to Cmder User Init!"
%print_verbose% "Cmder is already configured, skipping to Cmder User Init!"
goto USER_CONFIG_START
)
@ -191,12 +191,12 @@ if defined GIT_INSTALL_ROOT (
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" goto :SPECIFIED_GIT
) else if "%fast_init%" == "1" (
if exist "%CMDER_ROOT%\vendor\git-for-windows\cmd\git.exe" (
%lib_console% debug_output "Skipping Git Auto-Detect!"
%print_debug% "Skipping Git Auto-Detect!"
goto :VENDORED_GIT
)
)
%lib_console% debug_output init.bat "Looking for Git install root..."
%print_debug% init.bat "Looking for Git install root..."
:: get the version information for vendored git binary
%lib_git% read_version VENDORED "%CMDER_ROOT%\vendor\git-for-windows\cmd" 2>nul
@ -218,31 +218,31 @@ for /F "delims=" %%F in ('where git.exe 2^>nul') do (
:VENDORED_GIT
if exist "%CMDER_ROOT%\vendor\git-for-windows" (
set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
%lib_console% debug_output "Using vendored Git '%GIT_VERSION_VENDORED%'..."
%print_debug% "Using vendored Git '%GIT_VERSION_VENDORED%'..."
goto :CONFIGURE_GIT
) else (
goto :NO_GIT
)
:SPECIFIED_GIT
%lib_console% debug_output "Using /GIT_INSTALL_ROOT..."
%print_debug% "Using /GIT_INSTALL_ROOT..."
goto :CONFIGURE_GIT
:FOUND_GIT
%lib_console% debug_output "Using found Git '%GIT_VERSION_USER%' from '%GIT_INSTALL_ROOT%..."
%print_debug% "Using found Git '%GIT_VERSION_USER%' from '%GIT_INSTALL_ROOT%..."
goto :CONFIGURE_GIT
:CONFIGURE_GIT
%lib_console% debug_output "Using Git from '%GIT_INSTALL_ROOT%..."
%print_debug% "Using Git from '%GIT_INSTALL_ROOT%..."
:: Add git to the path
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" %lib_path% enhance_path "%GIT_INSTALL_ROOT%\cmd" ""
:: Add the unix commands at the end to not shadow windows commands like more
if %nix_tools% equ 1 (
%lib_console% verbose_output "Preferring Windows commands"
%print_verbose% "Preferring Windows commands"
set "path_position=append"
) else (
%lib_console% verbose_output "Preferring *nix commands"
%print_verbose% "Preferring *nix commands"
set "path_position="
)
@ -268,7 +268,7 @@ if not defined git_locale for /F "tokens=* delims=" %%F in ('where env.exe 2^>nu
setlocal enabledelayedexpansion
if defined git_locale (
REM !lib_console! debug_output init.bat "Env Var - git_locale=!git_locale!"
REM %print_debug% init.bat "Env Var - git_locale=!git_locale!"
if not defined LANG (
for /F "delims=" %%F in ('!git_locale! -uU 2') do (
set "LANG=%%F"
@ -277,8 +277,8 @@ if defined git_locale (
)
endlocal && set LANG=%LANG%
%lib_console% debug_output init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
%lib_console% debug_output init.bat "Found Git in: '%GIT_INSTALL_ROOT%'"
%print_debug% init.bat "Env Var - GIT_INSTALL_ROOT=%GIT_INSTALL_ROOT%"
%print_debug% init.bat "Found Git in: '%GIT_INSTALL_ROOT%'"
goto :PATH_ENHANCE
:NO_GIT
@ -361,12 +361,12 @@ if exist "%GIT_INSTALL_ROOT%\post-install.bat" (
:: Set home path
if not defined HOME set "HOME=%USERPROFILE%"
%lib_console% debug_output init.bat "Env Var - HOME=%HOME%"
%print_debug% init.bat "Env Var - HOME=%HOME%"
set "initialConfig=%CMDER_ROOT%\config\user_profile.cmd"
if exist "%CMDER_ROOT%\config\user_profile.cmd" (
REM Create this file and place your own command in there
%lib_console% debug_output init.bat "Calling - %CMDER_ROOT%\config\user_profile.cmd"
%print_debug% init.bat "Calling - %CMDER_ROOT%\config\user_profile.cmd"
call "%CMDER_ROOT%\config\user_profile.cmd"
)
@ -374,7 +374,7 @@ if defined CMDER_USER_CONFIG (
set "initialConfig=%CMDER_USER_CONFIG%\user_profile.cmd"
if exist "%CMDER_USER_CONFIG%\user_profile.cmd" (
REM Create this file and place your own command in there
%lib_console% debug_output init.bat "Calling - %CMDER_USER_CONFIG%\user_profile.cmd"
%print_debug% init.bat "Calling - %CMDER_USER_CONFIG%\user_profile.cmd"
call "%CMDER_USER_CONFIG%\user_profile.cmd"
)
)