Update git for windows to 2.10.0
This updates the version of git for windows retrieved with depot_tools to 2.10.0.
This uses the git download method of upstream commit 3af17b9928870382ff8633a3a4861b0b7772e9d1
Change-Id: I8add580a232e072950c33112b2885c20114bc075
diff --git a/bootstrap/win/git-bash.template.sh b/bootstrap/win/git-bash.template.sh
new file mode 100644
index 0000000..d1e9aee
--- /dev/null
+++ b/bootstrap/win/git-bash.template.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+export EDITOR=${EDITOR:=notepad}
+WIN_BASE=`dirname $0`
+UNIX_BASE=`cygpath "$WIN_BASE"`
+export PATH=$PATH:$UNIX_BASE/PYTHON_BIN_DIR:$UNIX_BASE/PYTHON_BIN_DIR/Scripts
+export PYTHON_DIRECT=1
+export PYTHONUNBUFFERED=1
+if [[ $# > 0 ]]; then
+ $UNIX_BASE/GIT_BIN_DIR/bin/bash.exe "$@"
+else
+ $UNIX_BASE/GIT_BIN_DIR/git-bash.exe &
+fi
diff --git a/bootstrap/win/git.template.bat b/bootstrap/win/git.template.bat
new file mode 100644
index 0000000..d3b9cbc
--- /dev/null
+++ b/bootstrap/win/git.template.bat
@@ -0,0 +1,5 @@
+@echo off
+setlocal
+if not defined EDITOR set EDITOR=notepad
+set PATH=%~dp0GIT_BIN_DIR\cmd;%PATH%
+"%~dp0GIT_BIN_DIR\GIT_PROGRAM" %*
diff --git a/bootstrap/win/win_tools.bat b/bootstrap/win/win_tools.bat
index 67c0542..0a512c9 100644
--- a/bootstrap/win/win_tools.bat
+++ b/bootstrap/win/win_tools.bat
@@ -3,8 +3,8 @@
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.
-:: This script will try to find if svn and python are accessible and it not,
-:: it will try to download it and 'install' it in depot_tools.
+:: This script will determine if python or git binaries need updates. It
+:: returns 123 if the user's shell must restart, otherwise !0 is failure
:: Sadly, we can't use SETLOCAL here otherwise it ERRORLEVEL is not correctly
:: returned.
@@ -56,76 +56,129 @@
set ERRORLEVEL=1
goto :END
+
:GIT_CHECK
-if "%DEPOT_TOOLS_GIT_BLEEDING%" == "1" (
- set GIT_VERSION=1.9.5.chromium.6
+
+:: must explicitly use FIND_EXE to prevent this from grabbing e.g. gnuwin32 or
+:: msys versions.
+set FIND_EXE=%SYSTEMROOT%\System32\find.exe
+
+:: Check to see if we're on a 32 or 64 bit system
+:: (parens) are necessary, otherwise batch puts an extra space after 32.
+reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | %FIND_EXE% /i "x86" > NUL && (set OS_BITS=32) || (set OS_BITS=64)
+
+if not exist "%WIN_TOOLS_ROOT_DIR%\.git_bleeding_edge" (
+ set GIT_VERSION=2.10.0
) else (
- set GIT_VERSION=1.9.5.chromium.6
+ set GIT_VERSION=2.8.3
)
-for /f "tokens=2 delims=[]" %%i in ('ver') do set VERSTR=%%i
-for /f "tokens=2,3 delims=. " %%i in ("%VERSTR%") do (set VERMAJOR=%%i & set VERMINOR=%%j)
-if %VERMAJOR% lss 5 set GIT_VERSION=%GIT_VERSION%-xp
-if %VERMAJOR% equ 5 if %VERMINOR% lss 2 set GIT_VERSION=%GIT_VERSION%-xp
+set GIT_VERSION=%GIT_VERSION%-%OS_BITS%
+
+set GIT_FETCH_URL=https://storage.googleapis.com/chrome-infra/PortableGit-%GIT_VERSION%-bit.7z.exe
+set GIT_DOWNLOAD_PATH=%ZIP_DIR%\git.7z.exe
+set GIT_BIN_DIR=git-%GIT_VERSION%_bin
+set GIT_INST_DIR=%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%
+set GIT_EXE_PATH=%GIT_INST_DIR%\bin\git.exe
:: Clean up any release which doesn't match the one we want.
-for /d %%i in (%WIN_TOOLS_ROOT_DIR%\git-*_bin) do (
- if not %%i == %WIN_TOOLS_ROOT_DIR%\git-%GIT_VERSION%_bin (
- rmdir /s /q "%%i"
+for /d %%i in ("%WIN_TOOLS_ROOT_DIR%\git-*_bin") do (
+ if not "%%i" == "%WIN_TOOLS_ROOT_DIR%\git-%GIT_VERSION%_bin" (
+ echo Cleaning old git installation %%i
+ rmdir /s /q "%%i" > NUL
)
)
-set GIT_BIN_DIR=git-%GIT_VERSION%_bin
-set GIT_ZIP_FILE=%GIT_BIN_DIR%.zip
-set GIT_ZIP_URL=https://commondatastorage.googleapis.com/chrome-infra/%GIT_ZIP_FILE%
if "%WIN_TOOLS_FORCE%" == "1" goto :GIT_INSTALL
-if exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\cmd\git.cmd" (
- call "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\cmd\git.cmd" --version 2>nul 1>nul
- if errorlevel 1 goto :GIT_INSTALL
- rem Several git versions can live side-by-side; check the top-level
- rem batch script to make sure it points to the desired version.
- find "%GIT_BIN_DIR%" "%WIN_TOOLS_ROOT_DIR%\git.bat" 2>nul 1>nul
- if errorlevel 1 goto :GIT_COPY_BATCH_FILES
- goto :END
-)
-goto :GIT_INSTALL
+if not exist "%GIT_EXE_PATH%" goto :GIT_INSTALL
+
+call "%GIT_EXE_PATH%" --version 2>nul 1>nul
+if errorlevel 1 goto :GIT_INSTALL
+
+:: Several git versions can live side-by-side; check the top-level
+:: batch script to make sure it points to the desired version.
+for %%f in (git.bat gitk.bat ssh.bat ssh-keygen.bat git-bash) do (
+ %FIND_EXE% "%GIT_BIN_DIR%" "%WIN_TOOLS_ROOT_DIR%\%%f" 2>nul 1>nul
+ if errorlevel 1 goto :GIT_MAKE_BATCH_FILES
+)
+if not exist %GIT_INST_DIR%\etc\profile.d\python.sh goto :GIT_MAKE_BATCH_FILES
+goto :SYNC_GIT_HELP_FILES
:GIT_INSTALL
echo Installing git %GIT_VERSION% (avg 1-2 min download) ...
-:: git is not accessible; check it out and create 'proxy' files.
-if exist "%ZIP_DIR%\git.zip" del "%ZIP_DIR%\git.zip"
-echo Fetching from %GIT_ZIP_URL%
-cscript //nologo //e:jscript "%~dp0get_file.js" %GIT_ZIP_URL% "%ZIP_DIR%\git.zip"
-if errorlevel 1 goto :GIT_FAIL
-:: Cleanup svn directory if it was existing.
-if exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\." rd /q /s "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%"
-:: Will create %GIT_BIN_DIR%\...
-cscript //nologo //e:jscript "%~dp0unzip.js" "%ZIP_DIR%\git.zip" "%WIN_TOOLS_ROOT_DIR%"
-if errorlevel 1 goto :GIT_FAIL
-if not exist "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\." goto :GIT_FAIL
-del "%ZIP_DIR%\git.zip"
-goto :GIT_COPY_BATCH_FILES
+if exist "%GIT_DOWNLOAD_PATH%" del "%GIT_DOWNLOAD_PATH%"
+echo Fetching from %GIT_FETCH_URL%
+cscript //nologo //e:jscript "%~dp0get_file.js" %GIT_FETCH_URL% "%GIT_DOWNLOAD_PATH%"
+if errorlevel 1 goto :GIT_FAIL
+:: Cleanup git directory if it already exists.
+if exist "%GIT_INST_DIR%\." rd /q /s "%GIT_INST_DIR%"
-:GIT_COPY_BATCH_FILES
+:: run PortableGit self-extractor
+:: -y : Be Quiet ("yes")
+:: -sd1 : Self delete SFX archive
+:: -InstallPath : Where to put the files
+:: -Directory : Run the post-extract program with this current-working-directory
+::
+:: Path slashes must be escaped or the 7zip sfx treats e.g. path\to\dir as
+:: path[tab]o\dir.
+set GIT_INST_DIR_ESC=%GIT_INST_DIR:\=\\%
+call "%GIT_DOWNLOAD_PATH%" -y -sd1 -InstallPath="%GIT_INST_DIR_ESC%" -Directory="%GIT_INST_DIR_ESC%"
+if errorlevel 1 goto :GIT_FAIL
+
+del "%GIT_DOWNLOAD_PATH%"
+if not exist "%GIT_INST_DIR%\." goto :GIT_FAIL
+
+set DID_UPGRADE=1
+
+:GIT_MAKE_BATCH_FILES
:: Create the batch files.
-call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\git.bat" "%WIN_TOOLS_ROOT_DIR%\git.bat" 1>nul
-call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\gitk.bat" "%WIN_TOOLS_ROOT_DIR%\gitk.bat" 1>nul
-call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\ssh.bat" "%WIN_TOOLS_ROOT_DIR%\ssh.bat" 1>nul
-call copy /y "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\ssh-keygen.bat" "%WIN_TOOLS_ROOT_DIR%\ssh-keygen.bat" 1>nul
+set GIT_TEMPL=%~dp0git.template.bat
+set SED=%GIT_INST_DIR%\usr\bin\sed.exe
+call "%SED%" -e "s/GIT_BIN_DIR/%GIT_BIN_DIR%/g" -e "s/GIT_PROGRAM/cmd\\\\git.exe/g" < %GIT_TEMPL% > "%WIN_TOOLS_ROOT_DIR%\git.bat"
+call "%SED%" -e "s/GIT_BIN_DIR/%GIT_BIN_DIR%/g" -e "s/GIT_PROGRAM/cmd\\\\gitk.exe/g" < %GIT_TEMPL% > "%WIN_TOOLS_ROOT_DIR%\gitk.bat"
+call "%SED%" -e "s/GIT_BIN_DIR/%GIT_BIN_DIR%/g" -e "s/GIT_PROGRAM/usr\\\\bin\\\\ssh.exe/g" < %GIT_TEMPL% > "%WIN_TOOLS_ROOT_DIR%\ssh.bat"
+call "%SED%" -e "s/GIT_BIN_DIR/%GIT_BIN_DIR%/g" -e "s/GIT_PROGRAM/usr\\\\bin\\\\ssh-keygen.exe/g" < %GIT_TEMPL% > "%WIN_TOOLS_ROOT_DIR%\ssh-keygen.bat"
+call "%SED%" -e "s/GIT_BIN_DIR/%GIT_BIN_DIR%/g" -e "s/PYTHON_BIN_DIR/python276_bin/g" < %~dp0git-bash.template.sh > "%WIN_TOOLS_ROOT_DIR%\git-bash"
+copy "%~dp0profile.d.python.sh" %GIT_INST_DIR%\etc\profile.d\python.sh > NUL
-:: Ensure autocrlf and filemode are set correctly.
-call "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\cmd\git.cmd" config --system core.autocrlf false
-call "%WIN_TOOLS_ROOT_DIR%\%GIT_BIN_DIR%\cmd\git.cmd" config --system core.filemode false
+:: Ensure various git configurations are set correctly at they system level.
+call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.autocrlf false
+call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.filemode false
+call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.preloadindex true
+call "%WIN_TOOLS_ROOT_DIR%\git.bat" config --system core.fscache true
+
+:SYNC_GIT_HELP_FILES
+:: Copy all the depot_tools docs into the mingw64 git docs root.
+:: /i : Make sure xcopy knows that the destination names a folder, not a file
+:: /q : Make xcopy quiet (though it still prints a `X File(s) copied` message
+:: which is why we have the > NUL)
+:: /d : Copy source files that are newer than the corresponding destination
+:: files only. This prevents excessive copying when none of the docs
+:: actually changed.
+:: /y : Don't prompt for overwrites (yes)
+xcopy /i /q /d /y "%WIN_TOOLS_ROOT_DIR%\man\html\*" "%GIT_INST_DIR%\mingw64\share\doc\git-doc" > NUL
+
+:: MSYS users need to restart their shell.
+if defined MSYSTEM if defined DID_UPGRADE (
+ echo.
+ echo.
+ echo IMPORTANT:
+ echo depot_tools' git distribution has been updated while inside of a MinGW
+ echo shell. In order to complete the upgrade, please exit the shell and re-run
+ echo `git bash`.
+ exit 123
+)
+
goto :END
-
:GIT_FAIL
echo ... Failed to checkout git automatically.
-echo You should get the "prebaked" version used at %GIT_ZIP_URL%
+echo You should get the "prebaked" version used at %GIT_FETCH_URL%
set ERRORLEVEL=1
goto :END
+
:returncode
set WIN_TOOLS_ROOT_URL=
set WIN_TOOLS_ROOT_DIR=