From 5fb7f6b77c485bb583666193e10f69e5d8e19739 Mon Sep 17 00:00:00 2001 From: luozexuan Date: Sun, 16 Aug 2015 11:47:16 +0800 Subject: [PATCH] make it possible to update via `git extras` --- Installation.md | 13 +++++++++---- bin/git-extras | 30 +++++++++++++++++++++++++++++- install.cmd | 3 ++- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/Installation.md b/Installation.md index 1cd5180..4956cb7 100644 --- a/Installation.md +++ b/Installation.md @@ -34,13 +34,18 @@ and the basic [msys2][1]. Second, clone the `git-extras` repo into any folder you like. ```bash git clone https://github.com/tj/git-extras.git +# checkout the latest tag (optional) +git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) ``` -After that, open the script `install.cmd` in the folder with any text editor you like. -Modify the `PREFIX` variable to where your `Git for Windows 2.x` is installed. + +After that, execute the `install.cmd` in the command prompt, with the path your `Git for Windows 2.x` is installed. For example, I install it in the folder called `C:\SCM\PortableGit` and the `PREFIX` should be `C:\SCM\PortableGit\mingw64` (for 64-bit release) -or `C:\SCM\PortableGit\mingw32` (for 32-bit release). -Third, execute the `install.cmd` directly or in the command prompt. +or `C:\SCM\PortableGit\mingw32` (for 32-bit release). So I will execute the `install.cmd` like this: +```batch +install.cmd "C:\SCM\PortableGit\mingw64" +``` + Last, please copy `colrm.exe` and `column.exe` from `folder-your-msys2-installed/usr/bin` to `folder-your-git-installed/usr/bin`. Enjoy `git-extras`! diff --git a/bin/git-extras b/bin/git-extras index 804f4c1..550c547 100755 --- a/bin/git-extras +++ b/bin/git-extras @@ -13,12 +13,40 @@ update() { && echo "... updated git-extras $VERSION -> $(git extras --version)" } +updateForWindows() { + local bin=$(which git-extras) + local prefix=${bin%/*/*} + local orig=$PWD + + # we need to clean up /tmp manually on windows + cd /tmp \ + && rm -rf ./git-extras \ + && echo "Setting up 'git-exras'...." \ + && git clone https://github.com/tj/git-extras.git &> /dev/null \ + && cd git-extras \ + && git checkout \ + $(git describe --tags $(git rev-list --tags --max-count=1)) \ + &> /dev/null \ + && ./install.cmd "$prefix" \ + && cd "$orig" \ + && echo "... updated git-extras $VERSION -> $(git extras --version)" + rm -rf /tmp/git-extras &> /dev/null +} + case "$1" in -v|--version) echo $VERSION && exit 0 ;; update) - update + platform=$(uname -s) + if [ $(expr substr "$platform" 1 9) = "CYGWIN_NT" ] || \ + [ $(expr substr "$platform" 1 10) = "MINGW32_NT" ] || \ + [ $(expr substr "$platform" 1 10) = "MINGW64_NT" ] + then + updateForWindows + else + update + fi ;; *) git extras --help diff --git a/install.cmd b/install.cmd index 3f76b2a..1e18665 100644 --- a/install.cmd +++ b/install.cmd @@ -1,5 +1,6 @@ @ECHO OFF SET PREFIX=C:\SCM\PortableGit\mingw64 +IF NOT "%~1"=="" SET PREFIX="%~1" SET HTMLDIR=%PREFIX%\share\doc\git-doc SET GITEXTRAS=%~dp0 @@ -22,6 +23,6 @@ FOR %%i in (%COMMANDS_WITHOUT_REPO%) DO ( MORE +2 %GITEXTRAS%\bin\%%i >> %PREFIX%\bin\%%i ) -ROBOCOPY %GITEXTRAS%\man %HTMLDIR% *.html +ROBOCOPY /IS %GITEXTRAS%\man %HTMLDIR% *.html @ECHO ON \ No newline at end of file