diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..8d038485f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+debian/files
+debian/*.substvars
+debian/*.debhelper.log
+debian/*/*
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 000000000..aded955fc
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,24 @@
+Authors are (ordered by first commit date):
+
+- Vincent Driessen
+- Benedikt Böhm
+- Daniel Truemper
+- Jason L. Shiffer
+- Randy Merrill
+- Rick Osborne
+- Mark Derricutt
+- Nowell Strite
+- Felipe Talavera
+- Guillaume-Jean Herbiet
+- Joseph A. Levin
+- Jannis Leidel
+- Konstantin Tjuterev
+- Kiall Mac Innes
+- Jon Bernard
+- Olivier Mengué
+- Emre Berge Ergenekon
+- Eric Holmes
+- Vedang Manerikar
+- Myke Hines
+
+Portions derived from other open source works are clearly marked.
diff --git a/Changes.mdown b/Changes.mdown
new file mode 100644
index 000000000..2281f2307
--- /dev/null
+++ b/Changes.mdown
@@ -0,0 +1,103 @@
+0.4.2:
+-----
+Release date: **not yet**
+
+* `git flow init` now detects situations where origin already has gitflow
+ branches set up, and behaves accordingly (thanks Emre Berge Ergenekon).
+
+* `git flow feature finish` can now be called without a feature branch
+ name(prefix) argument and will finish the current branch, if on any.
+
+* `git flow feature pull` now has a `-r` flag, to support `pull --rebase`
+ semantics (thanks Vedang Manerikar).
+
+* Various minor bug fixes related to internal argument passing.
+
+* Improved some documentation.
+
+* Better support for Windows and BSD users.
+
+* Add package installer for the Windows platform.
+
+0.4.1:
+-----
+Release date: **2011/02/04**
+
+* New option `-d` added to `git flow init`, to initialize with defaults without
+ asking for input interactively. Ideal for creating git-flow enabled repos in
+ custom scripts.
+
+* The parsing issues related to git-flow feature's flags are now dealt with on
+ all known platforms. (Fixed #54, #62, #86, #97)
+
+* Escape queries for detecting branch/tag names. (Fixed #91)
+
+
+0.4:
+---
+Release date: **2010/10/18**
+
+* The flag parsing issues of git-flow subcommands are solved for most
+ platforms.
+
+* `git flow {feature,hotfix,release} finish` now takes a `-k` flag, to keep the
+ branch around after finishing.
+
+* `git flow release finish` takes a `-n` flag, to skip tagging.
+
+* For consistency, `git flow {release,hotfix}` now, too, have a `publish` and
+ `track` subcommand, just like `feature`.
+
+* Various minor fixes.
+
+
+0.3:
+----
+Release date: **2010/07/22**
+
+* New subcommands for `git flow feature`:
+ - **checkout**:
+ For easily checking out features by their short name. Even allows
+ unique prefixes as arguments (see below).
+
+ - **pull**:
+ This subcommand allows you to painlessly work on a feature branch
+ together with another peer. This is especially valuable for doing
+ peer reviews of other people's code. For more detailed info, see the
+ [commit log][1].
+
+* Easier addressing of branch names by using name prefixes.
+ For example, when using:
+
+ git flow feature finish fo
+
+ this automatically finishes the feature branch `foobar` if that's the only
+ feature branch name starting with `fo`.
+
+* No force flag anymore for new feature branches
+ `git flow feature start` lost its `-f` (force) flag. You now don't
+ have to be in a clean repo anymore to start a new feature branch. This
+ avoids the manual `git stash`, `git flow feature start`, `git stash
+ pop` cycle.
+
+* You can use `git-flow` in stand-alone repo's now.
+ This means it does not assume you have an `origin` repository.
+ (Thanks [Mark][2].)
+
+* No commands fetch from `origin` by default anymore.
+ There were some issues related to disabling this flag on some platforms.
+
+* Init guesses branch names you may want to use for `develop` and `master`.
+
+* Added super-easy installation script. (Thanks [Rick][3].)
+
+* Added BSD license.
+
+[1]: http://github.com/nvie/gitflow/commit/f68d405cc3a11e9df3671f567658a6ab6ed8e0a1
+[2]: http://github.com/talios
+[3]: http://github.com/rickosborne
+
+
+Older versions
+--------------
+No change history is recorded for pre-0.3 releases.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000..cedd18231
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,26 @@
+Copyright 2010 Vincent Driessen. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+The views and conclusions contained in the software and documentation are those
+of the authors and should not be interpreted as representing official policies,
+either expressed or implied, of Vincent Driessen.
diff --git a/Makefile b/Makefile
index 11bf22d91..fbbfd2c00 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,33 @@
-AUTO_DETECTED_GIT_EXEC_PATH := $(shell git --exec-path 2>/dev/null || echo /usr/libexec/git-core)
-GIT_EXEC_PATH=$(AUTO_DETECTED_GIT_EXEC_PATH)
+#
+# Copyright 2010 Vincent Driessen. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of Vincent Driessen.
+#
+
+prefix=/usr/local
# files that need mode 755
EXEC_FILES=git-flow
@@ -20,11 +48,11 @@ all:
install:
@test -f gitflow-shFlags || (echo "Run 'git submodule init && git submodule update' first." ; exit 1 )
- install -d -m 0755 $(GIT_EXEC_PATH)
- install -m 0755 $(EXEC_FILES) $(GIT_EXEC_PATH)
- install -m 0644 $(SCRIPT_FILES) $(GIT_EXEC_PATH)
+ install -d -m 0755 $(prefix)/bin
+ install -m 0755 $(EXEC_FILES) $(prefix)/bin
+ install -m 0644 $(SCRIPT_FILES) $(prefix)/bin
uninstall:
- test -d $(GIT_EXEC_PATH) && \
- cd $(GIT_EXEC_PATH) && \
+ test -d $(prefix)/bin && \
+ cd $(prefix)/bin && \
rm -f $(EXEC_FILES) $(SCRIPT_FILES)
diff --git a/README.mdown b/README.mdown
index ed5be3313..b720b125e 100644
--- a/README.mdown
+++ b/README.mdown
@@ -1,64 +1,98 @@
+> [!IMPORTANT]
+>
+> # ⚠️ git-flow has moved to git-flow-next!
+>
+> **This repository is no longer maintained.** The wonderful team at [Tower](https://www.git-tower.com/) has created [**git-flow-next**](https://git-flow.sh) — a modern, fully customizable evolution of git-flow, built on a generic branch dependency model. It’s fully backward compatible with git-flow, open source, and actively maintained.
+>
+> ### Get started with git-flow-next:
+>
+> - **Website:** https://git-flow.sh
+> - **GitHub:** https://github.com/gittower/git-flow-next
+> - **Evolution Story:** Read about the journey from git-flow → git-flow-avh → git-flow-next in [their blog post](https://git-flow.sh/blog)
+>
+> ### Why git-flow-next?
+>
+> git-flow-next builds upon the foundation laid by the original git-flow, offering:
+>
+> - Full customization of branch names and workflow
+> - Modern implementation with active maintenance
+> - Backward compatibility with existing git-flow workflows
+> - Upcoming features like stacked branches and topic branch syncing
+>
+> ### Thank you ❤️
+>
+> To everyone who has used, contributed to, and supported git-flow over the past 15+ years — thank you! Your feedback, contributions, and adoption made git-flow one of the most widely-used Git workflow tools. Special thanks to Peter van der Does for maintaining git-flow-avh, and to the folks at Tower for carrying the torch forward with git-flow-next.
+
+---
+
+(Below, you’ll find the original documentation for historical reference.)
+
+---
+
git-flow
========
+
A collection of Git extensions to provide high-level repository operations
for Vincent Driessen's [branching model](http://nvie.com/git-model "original
blog post").
-> **IMPORTANT NOTE:**
-> In release 0.2, the order of the arguments has changed to provide a logical
-> subcommand hierarchy.
-
-
-Installing git-flow
--------------------
-After downloading the sources from Github, also fetch the submodules:
+Getting started
+---------------
+For the best introduction to get started with `git flow`, please read Jeff
+Kreeftmeijer's blog post:
- $ git submodule init
- $ git submodule update
+[http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/](http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/)
-Then, you can install `git-flow`, using:
+Or have a look at one of these screen casts:
- $ sudo make install
+* [How to use a scalable Git branching model called git-flow](http://buildamodule.com/video/change-management-and-version-control-deploying-releases-features-and-fixes-with-git-how-to-use-a-scalable-git-branching-model-called-gitflow) (by Build a Module)
+* [A short introduction to git-flow](http://vimeo.com/16018419) (by Mark Derricutt)
+* [On the path with git-flow](http://codesherpas.com/screencasts/on_the_path_gitflow.mov) (by Dave Bock)
-By default, this will look for the directory where Git is already installed,
-and install the git-flow extension alongside the other Git subcommands. If git
-is not on the system's `PATH`, it tries `/usr/libexec/git-core`. To explicitly
-override this setting in case you have installed Git in another location, use:
- $ sudo make GIT_EXEC_PATH=/your/custom/path install
+Installing git-flow
+-------------------
+See the Wiki for up-to-date [Installation Instructions](https://github.com/nvie/gitflow/wiki/Installation).
-You rarely need to override this manually, the default 'make install' should do
-fine.
-Or simply point your `PATH` environment variable to your git-flow checkout
-directory.
+Integration with your shell
+---------------------------
+For those who use the [Bash](http://www.gnu.org/software/bash/) or
+[ZSH](http://www.zsh.org) shell, please check out the excellent work on the
+[git-flow-completion](http://github.com/bobthecow/git-flow-completion) project
+by [bobthecow](http://github.com/bobthecow). It offers tab-completion for all
+git-flow subcommands and branch names.
-Please help out
----------------
-This project is still under development. Feedback and suggestions are very
-welcome and I encourage you to use the [Issues
-list](http://github.com/nvie/gitflow/issues) on Github to provide that
-feedback.
+FAQ
+---
+See the [FAQ](http://github.com/nvie/gitflow/wiki/FAQ) section of the project
+Wiki.
-Feel free to fork this repo and to commit your additions.
+License terms
+-------------
+git-flow is published under the liberal terms of the BSD License, see the
+[LICENSE](LICENSE) file. Although the BSD License does not require you to share
+any modifications you make to the source code, you are very much encouraged and
+invited to contribute back your modifications to the community, preferably
+in a Github fork, of course.
-Typical usage:
---------------
### Initialization
To initialize a new repo with the basic branch structure, use:
- git flow init
+ git flow init [-d]
This will then interactively prompt you with some questions on which branches
you would like to use as development and production branches, and how you
would like your prefixes be named. You may simply press Return on any of
those questions to accept the (sane) default suggestions.
+The ``-d`` flag will accept all defaults.
+
### Creating feature/release/hotfix/support branches
@@ -70,6 +104,11 @@ those questions to accept the (sane) default suggestions.
For feature branches, the `` arg must be a commit on `develop`.
+* To push/pull a feature branch to the remote repository, use:
+
+ git flow feature publish
+ git flow feature pull
+
* To list/start/finish release branches, use:
git flow release
@@ -92,4 +131,3 @@ those questions to accept the (sane) default suggestions.
git flow support start
For support branches, the `` arg must be a commit on `master`.
-
diff --git a/contrib/gitflow-installer.sh b/contrib/gitflow-installer.sh
new file mode 100644
index 000000000..0e92ffcef
--- /dev/null
+++ b/contrib/gitflow-installer.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+# git-flow make-less installer for *nix systems, by Rick Osborne
+# Based on the git-flow core Makefile:
+# http://github.com/nvie/gitflow/blob/master/Makefile
+
+# Licensed under the same restrictions as git-flow:
+# http://github.com/nvie/gitflow/blob/develop/LICENSE
+
+# Does this need to be smarter for each host OS?
+if [ -z "$INSTALL_PREFIX" ] ; then
+ INSTALL_PREFIX="/usr/local/bin"
+fi
+
+if [ -z "$REPO_NAME" ] ; then
+ REPO_NAME="gitflow"
+fi
+
+if [ -z "$REPO_HOME" ] ; then
+ REPO_HOME="http://github.com/nvie/gitflow.git"
+fi
+
+EXEC_FILES="git-flow"
+SCRIPT_FILES="git-flow-init git-flow-feature git-flow-hotfix git-flow-release git-flow-support git-flow-version gitflow-common gitflow-shFlags"
+SUBMODULE_FILE="gitflow-shFlags"
+
+echo "### gitflow no-make installer ###"
+
+case "$1" in
+ uninstall)
+ echo "Uninstalling git-flow from $INSTALL_PREFIX"
+ if [ -d "$INSTALL_PREFIX" ] ; then
+ for script_file in $SCRIPT_FILES $EXEC_FILES ; do
+ echo "rm -vf $INSTALL_PREFIX/$script_file"
+ rm -vf "$INSTALL_PREFIX/$script_file"
+ done
+ else
+ echo "The '$INSTALL_PREFIX' directory was not found."
+ echo "Do you need to set INSTALL_PREFIX ?"
+ fi
+ exit
+ ;;
+ help)
+ echo "Usage: [environment] gitflow-installer.sh [install|uninstall]"
+ echo "Environment:"
+ echo " INSTALL_PREFIX=$INSTALL_PREFIX"
+ echo " REPO_HOME=$REPO_HOME"
+ echo " REPO_NAME=$REPO_NAME"
+ exit
+ ;;
+ *)
+ echo "Installing git-flow to $INSTALL_PREFIX"
+ if [ -d "$REPO_NAME" -a -d "$REPO_NAME/.git" ] ; then
+ echo "Using existing repo: $REPO_NAME"
+ else
+ echo "Cloning repo from GitHub to $REPO_NAME"
+ git clone "$REPO_HOME" "$REPO_NAME"
+ fi
+ if [ -f "$REPO_NAME/$SUBMODULE_FILE" ] ; then
+ echo "Submodules look up to date"
+ else
+ echo "Updating submodules"
+ lastcwd=$PWD
+ cd "$REPO_NAME"
+ git submodule init
+ git submodule update
+ cd "$lastcwd"
+ fi
+ install -v -d -m 0755 "$INSTALL_PREFIX"
+ for exec_file in $EXEC_FILES ; do
+ install -v -m 0755 "$REPO_NAME/$exec_file" "$INSTALL_PREFIX"
+ done
+ for script_file in $SCRIPT_FILES ; do
+ install -v -m 0644 "$REPO_NAME/$script_file" "$INSTALL_PREFIX"
+ done
+ exit
+ ;;
+esac
diff --git a/contrib/msysgit-install.cmd b/contrib/msysgit-install.cmd
new file mode 100644
index 000000000..994235c79
--- /dev/null
+++ b/contrib/msysgit-install.cmd
@@ -0,0 +1,77 @@
+@echo off
+setlocal
+if not "%~1"=="" set GIT_HOME=%~f1
+if "%GIT_HOME%"=="" call :FindGitHome "git.cmd"
+
+if exist "%GIT_HOME%" goto :GitHomeOK
+
+echo MsysGit installation directory not found.>&2
+echo Try to give the directory name on the command line:>&2
+echo %0 "%ProgramFiles%\Git"
+endlocal
+exit /B 1
+
+:GitHomeOK
+set ERR=0
+
+echo Installing gitflow into "%GIT_HOME%"...
+
+call :ChkGetopt getopt.exe || set ERR=1
+if %ERR%==1 goto :End
+echo getopt.exe... Found
+
+if not exist "%GIT_HOME%\bin\git-flow" goto :Install
+echo GitFlow is already installed.>&2
+set /p mychoice="Do you want to replace it [y/n]"
+if "%mychoice%"=="y" goto :DeleteOldFiles
+goto :Abort
+
+:DeleteOldFiles
+echo Deleting old files...
+for /F %%i in ("%GIT_HOME%\git-flow*" "%GIT_HOME%\gitflow-*") do if exist "%%~fi" del /F /Q "%%~fi"
+
+:Install
+echo Copying files...
+::goto :EOF
+xcopy "%~dp0\..\git-flow" "%GIT_HOME%\bin" /Y /R /F
+if errorlevel 4 if not errorlevel 5 goto :AccessDenied
+if errorlevel 1 set ERR=1
+xcopy "%~dp0\..\git-flow*" "%GIT_HOME%\bin" /Y /R /F || set ERR=1
+xcopy "%~dp0\..\gitflow-*" "%GIT_HOME%\bin" /Y /R /F || set ERR=1
+xcopy "%~dp0\..\shFlags\src\shflags" "%GIT_HOME%\bin\gitflow-shFlags" /Y /R /F || set ERR=1
+
+if %ERR%==1 choice /T 30 /C Y /D Y /M "Some unexpected errors happened. Sorry, you'll have to fix them by yourself."
+
+:End
+endlocal & exit /B %ERR%
+goto :EOF
+
+:AccessDenied
+set ERR=1
+echo.
+echo You should run this script with "Full Administrator" rights:>&2
+echo - Right-click with Shift on the script from the Explorer>&2
+echo - Select "Run as administrator">&2
+choice /T 30 /C YN /D Y /N >nul
+goto :End
+
+:Abort
+echo Installation canceled.>&2
+set ERR=1
+goto :End
+
+:ChkGetopt
+:: %1 is getopt.exe
+if exist "%GIT_HOME%\bin\%1" goto :EOF
+if exist "%USERPROFILE%\bin\%1" goto :EOF
+if exist "%~f$PATH:1" goto :EOF
+echo %GIT_HOME%\bin\%1 not found.>&2
+echo You have to install this file manually. See the GitFlow README.
+exit /B 1
+
+:FindGitHome
+setlocal
+set GIT_CMD_DIR=%~dp$PATH:1
+if "%GIT_CMD_DIR%"=="" endlocal & goto :EOF
+endlocal & set GIT_HOME=%GIT_CMD_DIR:~0,-5%
+goto :EOF
diff --git a/git-flow b/git-flow
index 84adc05e4..fd16d5168 100755
--- a/git-flow
+++ b/git-flow
@@ -4,21 +4,50 @@
# repository operations for Vincent Driessen's branching model.
#
# Original blog post presenting this model is found at:
-# http://nvie.com/archives/323
+# http://nvie.com/git-model
#
# Feel free to contribute to this project at:
# http://github.com/nvie/gitflow
#
-# Copyright (c) 2010 by Vincent Driessen
-# Copyright (c) 2010 by Benedikt Böhm
+# Copyright 2010 Vincent Driessen. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of Vincent Driessen.
#
+# set this to workaround expr problems in shFlags on freebsd
+if uname -s | egrep -iq 'bsd'; then export EXPR_COMPAT=1; fi
+
# enable debug mode
if [ "$DEBUG" = "yes" ]; then
set -x
fi
-export GITFLOW_DIR=$(dirname "$0")
+# The sed expression here replaces all backslashes by forward slashes.
+# This helps our Windows users, while not bothering our Unix users.
+export GITFLOW_DIR=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
usage() {
echo "usage: git flow "
@@ -43,9 +72,19 @@ main() {
# load common functionality
. "$GITFLOW_DIR/gitflow-common"
+ # This environmental variable fixes non-POSIX getopt style argument
+ # parsing, effectively breaking git-flow subcommand parsing on several
+ # Linux platforms.
+ export POSIXLY_CORRECT=1
+
# use the shFlags project to parse the command line arguments
. "$GITFLOW_DIR/gitflow-shFlags"
FLAGS_PARENT="git flow"
+
+ # allow user to request git action logging
+ DEFINE_boolean show_commands false 'show actions taken (git commands)' g
+
+ # do actual parsing
FLAGS "$@" || exit $?
eval set -- "${FLAGS_ARGV}"
@@ -65,7 +104,7 @@ main() {
# in that case, we interpret this arg as a flag for the default
# command
SUBACTION="default"
- if [ "$1" != "" ] && ! echo "$1" | grep -q "^-"; then
+ if [ "$1" != "" ] && { ! echo "$1" | grep -q "^-"; } then
SUBACTION="$1"; shift
fi
if ! type "cmd_$SUBACTION" >/dev/null 2>&1; then
@@ -75,14 +114,10 @@ main() {
fi
# run the specified action
- cmd_$SUBACTION "$@"
+ if [ $SUBACTION != "help" ] && [ $SUBCOMMAND != "init" ] ; then
+ init
+ fi
+ cmd_$SUBACTION "$@"
}
-# helper functions for common reuse
-max() { if [ "$1" -gt "$2" ]; then echo "$1"; else echo "$2"; fi; }
-
-# convenience functions for checking whether flags have been set or not
-flag() { eval FLAG=\$FLAGS_$1; [ $FLAG -eq $FLAGS_TRUE ]; }
-noflag() { eval FLAG=\$FLAGS_$1; [ $FLAG -ne $FLAGS_TRUE ]; }
-
main "$@"
diff --git a/git-flow-feature b/git-flow-feature
index d8d4bb79d..55198ad82 100644
--- a/git-flow-feature
+++ b/git-flow-feature
@@ -3,28 +3,56 @@
# repository operations for Vincent Driessen's branching model.
#
# Original blog post presenting this model is found at:
-# http://nvie.com/archives/323
+# http://nvie.com/git-model
#
# Feel free to contribute to this project at:
# http://github.com/nvie/gitflow
#
-# Copyright (c) 2010 by Vincent Driessen
-# Copyright (c) 2010 by Benedikt Böhm
+# Copyright 2010 Vincent Driessen. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of Vincent Driessen.
#
-require_git_repo
-require_gitflow_initialized
-gitflow_load_settings
-PREFIX=$(git config --get gitflow.prefix.feature)
+init() {
+ require_git_repo
+ require_gitflow_initialized
+ gitflow_load_settings
+ PREFIX=$(git config --get gitflow.prefix.feature)
+}
usage() {
echo "usage: git flow feature [list] [-v]"
- echo " git flow feature start [-Ff] []"
- echo " git flow feature finish [-rF] "
+ echo " git flow feature start [-F] []"
+ echo " git flow feature finish [-rFkDS] []"
echo " git flow feature publish "
echo " git flow feature track "
echo " git flow feature diff []"
echo " git flow feature rebase [-i] []"
+ echo " git flow feature checkout []"
+ echo " git flow feature pull [-r] []"
}
cmd_default() {
@@ -41,9 +69,14 @@ cmd_list() {
feature_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX")
if [ -z "$feature_branches" ]; then
warn "No feature branches exist."
+ warn ""
+ warn "You can start a new feature branch:"
+ warn ""
+ warn " git flow feature start []"
+ warn ""
exit 0
fi
- current_branch=$(git branch | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
+ current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
short_names=$(echo "$feature_branches" | sed "s ^$PREFIX g")
# determine column width first
@@ -112,21 +145,30 @@ expand_nameprefix_arg() {
esac
}
+use_current_feature_branch_name() {
+ local current_branch=$(git_current_branch)
+ if startswith "$current_branch" "$PREFIX"; then
+ BRANCH=$current_branch
+ NAME=${BRANCH#$PREFIX}
+ else
+ warn "The current HEAD is no feature branch."
+ warn "Please specify a argument."
+ exit 1
+ fi
+}
+
expand_nameprefix_arg_or_current() {
if [ "$NAME" != "" ]; then
expand_nameprefix_arg
require_branch "$PREFIX$NAME"
else
- local current_branch=$(git_current_branch)
- if startswith "$current_branch" "$PREFIX"; then
- BRANCH=$current_branch
- NAME=${BRANCH#$PREFIX}
- else
- warn "The current HEAD is no feature branch."
- warn "To diff a feature, specify a argument."
- usage
- exit 1
- fi
+ use_current_feature_branch_name
+ fi
+}
+
+name_or_current() {
+ if [ -z "$NAME" ]; then
+ use_current_feature_branch_name
fi
}
@@ -140,28 +182,39 @@ parse_args() {
BRANCH=$PREFIX$NAME
}
+parse_remote_name() {
+ # parse options
+ FLAGS "$@" || exit $?
+ eval set -- "${FLAGS_ARGV}"
+
+ # read arguments into global variables
+ REMOTE=$1
+ NAME=$2
+ BRANCH=$PREFIX$NAME
+}
+
cmd_start() {
DEFINE_boolean fetch false 'fetch from origin before performing local operation' F
- DEFINE_boolean force false 'force creation of feature branch (ignores dirty working tree)' f
parse_args "$@"
BASE=${2:-$DEVELOP_BRANCH}
require_name_arg
# sanity checks
- if noflag force; then
- require_clean_working_tree
- fi
require_branch_absent "$BRANCH"
# update the local repo with remote changes, if asked
if flag fetch; then
- git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
+ git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
fi
- require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ # if the origin branch counterpart exists, assert that the local branch
+ # isn't behind it (to avoid unnecessary rebasing)
+ if git_branch_exists "$ORIGIN/$DEVELOP_BRANCH"; then
+ require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ fi
# create branch
- if ! git checkout -b "$BRANCH" "$BASE"; then
+ if ! git_do checkout -b "$BRANCH" "$BASE"; then
die "Could not create feature branch '$BRANCH'"
fi
@@ -172,15 +225,18 @@ cmd_start() {
echo ""
echo "Now, start committing on your feature. When done, use:"
echo ""
- echo " git flow finish feature $NAME"
+ echo " git flow feature finish $NAME"
echo
}
cmd_finish() {
DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
- DEFINE_boolean rebase false 'rebase instead of merge' r
+ DEFINE_boolean rebase false "rebase instead of merge" r
+ DEFINE_boolean keep false "keep branch after performing finish" k
+ DEFINE_boolean force_delete false "force delete feature branch after finish" D
+ DEFINE_boolean squash false "squash feature during merge" S
parse_args "$@"
- expand_nameprefix_arg
+ expand_nameprefix_arg_or_current
# sanity checks
require_branch "$BRANCH"
@@ -229,14 +285,19 @@ cmd_finish() {
require_clean_working_tree
# update local repo with remote changes first, if asked
- if flag fetch; then
- git fetch -q "$ORIGIN" "$BRANCH"
+ if has "$ORIGIN/$BRANCH" $(git_remote_branches); then
+ if flag fetch; then
+ git_do fetch -q "$ORIGIN" "$BRANCH"
+ git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
+ fi
fi
- if has "$ORIGIN/$BRANCH" "$(git_remote_branches)"; then
+ if has "$ORIGIN/$BRANCH" $(git_remote_branches); then
require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH"
fi
- require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then
+ require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ fi
# if the user wants to rebase, do that first
if flag rebase; then
@@ -250,11 +311,17 @@ cmd_finish() {
fi
# merge into BASE
- git checkout "$DEVELOP_BRANCH"
+ git_do checkout "$DEVELOP_BRANCH"
if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
- git merge --ff "$BRANCH"
+ git_do merge --ff "$BRANCH"
else
- git merge --no-ff "$BRANCH"
+ if noflag squash; then
+ git_do merge --no-ff "$BRANCH"
+ else
+ git_do merge --squash "$BRANCH"
+ git_do commit
+ git_do merge "$BRANCH"
+ fi
fi
if [ $? -ne 0 ]; then
@@ -284,15 +351,27 @@ helper_finish_cleanup() {
# delete branch
if flag fetch; then
- git push "$ORIGIN" ":refs/heads/$BRANCH"
+ git_do push "$ORIGIN" ":refs/heads/$BRANCH"
+ fi
+
+
+ if noflag keep; then
+ if flag force_delete; then
+ git_do branch -D "$BRANCH"
+ else
+ git_do branch -d "$BRANCH"
+ fi
fi
- git branch -d "$BRANCH"
echo
echo "Summary of actions:"
echo "- The feature branch '$BRANCH' was merged into '$DEVELOP_BRANCH'"
#echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported
- echo "- Feature branch '$BRANCH' has been removed"
+ if flag keep; then
+ echo "- Feature branch '$BRANCH' is still available"
+ else
+ echo "- Feature branch '$BRANCH' has been removed"
+ fi
echo "- You are now on branch '$DEVELOP_BRANCH'"
echo
}
@@ -304,17 +383,17 @@ cmd_publish() {
# sanity checks
require_clean_working_tree
require_branch "$BRANCH"
- git fetch -q "$ORIGIN"
+ git_do fetch -q "$ORIGIN"
require_branch_absent "$ORIGIN/$BRANCH"
# create remote branch
- git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
- git fetch -q "$ORIGIN"
+ git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
+ git_do fetch -q "$ORIGIN"
# configure remote tracking
- git config "branch.$BRANCH.remote" "$ORIGIN"
- git config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
- git checkout "$BRANCH"
+ git_do config "branch.$BRANCH.remote" "$ORIGIN"
+ git_do config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
+ git_do checkout "$BRANCH"
echo
echo "Summary of actions:"
@@ -331,11 +410,11 @@ cmd_track() {
# sanity checks
require_clean_working_tree
require_branch_absent "$BRANCH"
- git fetch -q "$ORIGIN"
+ git_do fetch -q "$ORIGIN"
require_branch "$ORIGIN/$BRANCH"
# create tracking branch
- git checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
+ git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
echo
echo "Summary of actions:"
@@ -361,6 +440,22 @@ cmd_diff() {
fi
}
+cmd_checkout() {
+ parse_args "$@"
+
+ if [ "$NAME" != "" ]; then
+ expand_nameprefix_arg
+ git_do checkout "$BRANCH"
+ else
+ die "Name a feature branch explicitly."
+ fi
+}
+
+cmd_co() {
+ # Alias for checkout
+ cmd_checkout "$@"
+}
+
cmd_rebase() {
DEFINE_boolean interactive false 'do an interactive rebase' i
parse_args "$@"
@@ -369,10 +464,67 @@ cmd_rebase() {
require_clean_working_tree
require_branch "$BRANCH"
- git checkout -q "$BRANCH"
+ git_do checkout -q "$BRANCH"
local OPTS=
if flag interactive; then
OPTS="$OPTS -i"
fi
- git rebase $OPTS "$DEVELOP_BRANCH"
+ git_do rebase $OPTS "$DEVELOP_BRANCH"
+}
+
+avoid_accidental_cross_branch_action() {
+ local current_branch=$(git_current_branch)
+ if [ "$BRANCH" != "$current_branch" ]; then
+ warn "Trying to pull from '$BRANCH' while currently on branch '$current_branch'."
+ warn "To avoid unintended merges, git-flow aborted."
+ return 1
+ fi
+ return 0
+}
+
+cmd_pull() {
+ #DEFINE_string prefix false 'alternative remote feature branch name prefix' p
+ DEFINE_boolean rebase false "pull with rebase" r
+ parse_remote_name "$@"
+
+ if [ -z "$REMOTE" ]; then
+ die "Name a remote explicitly."
+ fi
+ name_or_current
+
+ # To avoid accidentally merging different feature branches into each other,
+ # die if the current feature branch differs from the requested $NAME
+ # argument.
+ local current_branch=$(git_current_branch)
+ if startswith "$current_branch" "$PREFIX"; then
+ # we are on a local feature branch already, so $BRANCH must be equal to
+ # the current branch
+ avoid_accidental_cross_branch_action || die
+ fi
+
+ require_clean_working_tree
+
+ if git_branch_exists "$BRANCH"; then
+ # Again, avoid accidental merges
+ avoid_accidental_cross_branch_action || die
+
+ # we already have a local branch called like this, so simply pull the
+ # remote changes in
+ if flag rebase; then
+ if ! git_do pull --rebase -q "$REMOTE" "$BRANCH"; then
+ warn "Pull was aborted. There might be conflicts during rebase or '$REMOTE' might be inaccessible."
+ exit 1
+ fi
+ else
+ git_do pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'."
+ fi
+
+ echo "Pulled $REMOTE's changes into $BRANCH."
+ else
+ # setup the local branch clone for the first time
+ git_do fetch -q "$REMOTE" "$BRANCH" || die "Fetch failed." # stores in FETCH_HEAD
+ git_do branch --no-track "$BRANCH" FETCH_HEAD || die "Branch failed."
+ git_do checkout -q "$BRANCH" || die "Checking out new local branch failed."
+ echo "Created local branch $BRANCH based on $REMOTE's $BRANCH."
+ fi
}
diff --git a/git-flow-hotfix b/git-flow-hotfix
index 586617811..ba485f6fe 100644
--- a/git-flow-hotfix
+++ b/git-flow-hotfix
@@ -3,25 +3,53 @@
# repository operations for Vincent Driessen's branching model.
#
# Original blog post presenting this model is found at:
-# http://nvie.com/archives/323
+# http://nvie.com/git-model
#
# Feel free to contribute to this project at:
# http://github.com/nvie/gitflow
#
-# Copyright (c) 2010 by Vincent Driessen
-# Copyright (c) 2010 by Benedikt Böhm
+# Copyright 2010 Vincent Driessen. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of Vincent Driessen.
#
-require_git_repo
-require_gitflow_initialized
-gitflow_load_settings
-VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
-PREFIX=$(git config --get gitflow.prefix.hotfix)
+init() {
+ require_git_repo
+ require_gitflow_initialized
+ gitflow_load_settings
+ VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
+ PREFIX=$(git config --get gitflow.prefix.hotfix)
+}
usage() {
echo "usage: git flow hotfix [list] [-v]"
echo " git flow hotfix start [-F] []"
- echo " git flow hotfix finish [-Fsump] "
+ echo " git flow hotfix finish [-Fsumpk] "
+ echo " git flow hotfix publish "
+ echo " git flow hotfix track "
}
cmd_default() {
@@ -38,9 +66,14 @@ cmd_list() {
hotfix_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX")
if [ -z "$hotfix_branches" ]; then
warn "No hotfix branches exist."
+ warn ""
+ warn "You can start a new hotfix branch:"
+ warn ""
+ warn " git flow hotfix start []"
+ warn ""
exit 0
fi
- current_branch=$(git branch | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
+ current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
short_names=$(echo "$hotfix_branches" | sed "s ^$PREFIX g")
# determine column width first
@@ -108,7 +141,7 @@ require_version_arg() {
}
require_base_is_on_master() {
- if ! git branch --contains "$BASE" 2>/dev/null \
+ if ! git branch --no-color --contains "$BASE" 2>/dev/null \
| sed 's/[* ] //g' \
| grep -q "^$MASTER_BRANCH\$"; then
die "fatal: Given base '$BASE' is not a valid commit on '$MASTER_BRANCH'."
@@ -124,7 +157,7 @@ require_no_existing_hotfix_branches() {
}
cmd_start() {
- DEFINE_boolean fetch true "fetch from $ORIGIN before performing finish" F
+ DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
parse_args "$@"
BASE=${2:-$MASTER_BRANCH}
require_version_arg
@@ -136,12 +169,14 @@ cmd_start() {
require_branch_absent "$BRANCH"
require_tag_absent "$VERSION_PREFIX$VERSION"
if flag fetch; then
- git fetch -q "$ORIGIN" "$MASTER_BRANCH"
+ git_do fetch -q "$ORIGIN" "$MASTER_BRANCH"
+ fi
+ if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
+ require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
fi
- require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
# create branch
- git checkout -b "$BRANCH" "$BASE"
+ git_do checkout -b "$BRANCH" "$BASE"
echo
echo "Summary of actions:"
@@ -157,12 +192,62 @@ cmd_start() {
echo
}
+cmd_publish() {
+ parse_args "$@"
+ require_version_arg
+
+ # sanity checks
+ require_clean_working_tree
+ require_branch "$BRANCH"
+ git_do fetch -q "$ORIGIN"
+ require_branch_absent "$ORIGIN/$BRANCH"
+
+ # create remote branch
+ git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
+ git_do fetch -q "$ORIGIN"
+
+ # configure remote tracking
+ git config "branch.$BRANCH.remote" "$ORIGIN"
+ git config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
+ git_do checkout "$BRANCH"
+
+ echo
+ echo "Summary of actions:"
+ echo "- A new remote branch '$BRANCH' was created"
+ echo "- The local branch '$BRANCH' was configured to track the remote branch"
+ echo "- You are now on branch '$BRANCH'"
+ echo
+}
+
+cmd_track() {
+ parse_args "$@"
+ require_version_arg
+
+ # sanity checks
+ require_clean_working_tree
+ require_branch_absent "$BRANCH"
+ git_do fetch -q "$ORIGIN"
+ require_branch "$ORIGIN/$BRANCH"
+
+ # create tracking branch
+ git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
+
+ echo
+ echo "Summary of actions:"
+ echo "- A new remote tracking branch '$BRANCH' was created"
+ echo "- You are now on branch '$BRANCH'"
+ echo
+}
+
cmd_finish() {
- DEFINE_boolean fetch true "fetch from $ORIGIN before performing finish" F
+ DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
DEFINE_boolean sign false "sign the release tag cryptographically" s
DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u
DEFINE_string message "" "use the given tag message" m
+ DEFINE_string messagefile "" "use the contents of the given file as tag message" f
DEFINE_boolean push false "push to $ORIGIN after performing finish" p
+ DEFINE_boolean keep false "keep branch after performing finish" k
+ DEFINE_boolean notag false "don't tag this release" n
parse_args "$@"
require_version_arg
@@ -175,71 +260,88 @@ cmd_finish() {
require_branch "$BRANCH"
require_clean_working_tree
if flag fetch; then
- git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
+ git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not fetch $MASTER_BRANCH from $ORIGIN."
- git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
+ git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not fetch $DEVELOP_BRANCH from $ORIGIN."
fi
- require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
- require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
+ require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
+ fi
+ if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then
+ require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ fi
# try to merge into master
# in case a previous attempt to finish this release branch has failed,
# but the merge into master was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
- git checkout "$MASTER_BRANCH" || \
+ git_do checkout "$MASTER_BRANCH" || \
die "Could not check out $MASTER_BRANCH."
- git merge --no-ff "$BRANCH" || \
+ git_do merge --no-ff "$BRANCH" || \
die "There were merge conflicts."
# TODO: What do we do now?
fi
- # try to tag the release
- # in case a previous attempt to finish this release branch has failed,
- # but the tag was set successful, we skip it now
- local tagname=$VERSION_PREFIX$VERSION
- if ! git_tag_exists "$tagname"; then
- local opts="-a"
- flag sign && opts="$opts -s"
- [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
- [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
- git tag $opts "$VERSION_PREFIX$VERSION" || \
- die "Tagging failed. Please run finish again to retry."
+ if noflag notag; then
+ # try to tag the release
+ # in case a previous attempt to finish this release branch has failed,
+ # but the tag was set successful, we skip it now
+ local tagname=$VERSION_PREFIX$VERSION
+ if ! git_tag_exists "$tagname"; then
+ local opts="-a"
+ flag sign && opts="$opts -s"
+ [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
+ [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
+ [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
+ eval git_do tag $opts "$VERSION_PREFIX$VERSION" "$BRANCH" || \
+ die "Tagging failed. Please run finish again to retry."
+ fi
fi
# try to merge into develop
# in case a previous attempt to finish this release branch has failed,
# but the merge into develop was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
- git checkout "$DEVELOP_BRANCH" || \
+ git_do checkout "$DEVELOP_BRANCH" || \
die "Could not check out $DEVELOP_BRANCH."
# TODO: Actually, accounting for 'git describe' pays, so we should
# ideally git merge --no-ff $tagname here, instead!
- git merge --no-ff "$BRANCH" || \
+ git_do merge --no-ff "$BRANCH" || \
die "There were merge conflicts."
# TODO: What do we do now?
fi
# delete branch
- git branch -d "$BRANCH"
+ if noflag keep; then
+ git_do branch -d "$BRANCH"
+ fi
if flag push; then
- git push "$ORIGIN" "$DEVELOP_BRANCH" || \
+ git_do push "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not push to $DEVELOP_BRANCH from $ORIGIN."
- git push "$ORIGIN" "$MASTER_BRANCH" || \
+ git_do push "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not push to $MASTER_BRANCH from $ORIGIN."
- git push --tags "$ORIGIN" || \
- die "Could not push tags to $ORIGIN."
+ if noflag notag; then
+ git_do push --tags "$ORIGIN" || \
+ die "Could not push tags to $ORIGIN."
+ fi
fi
echo
echo "Summary of actions:"
echo "- Latest objects have been fetched from '$ORIGIN'"
echo "- Hotfix branch has been merged into '$MASTER_BRANCH'"
- echo "- The hotfix was tagged '$VERSION_PREFIX$VERSION'"
+ if noflag notag; then
+ echo "- The hotfix was tagged '$VERSION_PREFIX$VERSION'"
+ fi
echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'"
- echo "- Hotfix branch '$BRANCH' has been deleted"
+ if flag keep; then
+ echo "- Hotfix branch '$BRANCH' is still available"
+ else
+ echo "- Hotfix branch '$BRANCH' has been deleted"
+ fi
if flag push; then
echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'"
fi
diff --git a/git-flow-init b/git-flow-init
index ffc9e96f0..5b4e7e807 100644
--- a/git-flow-init
+++ b/git-flow-init
@@ -3,17 +3,41 @@
# repository operations for Vincent Driessen's branching model.
#
# Original blog post presenting this model is found at:
-# http://nvie.com/archives/323
+# http://nvie.com/git-model
#
# Feel free to contribute to this project at:
# http://github.com/nvie/gitflow
#
-# Copyright (c) 2010 by Vincent Driessen
-# Copyright (c) 2010 by Benedikt Böhm
+# Copyright 2010 Vincent Driessen. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of Vincent Driessen.
#
usage() {
- echo "usage: git flow init [-f]"
+ echo "usage: git flow init [-fd]"
}
parse_args() {
@@ -25,10 +49,11 @@ parse_args() {
# Default entry when no SUBACTION is given
cmd_default() {
DEFINE_boolean force false 'force setting of gitflow branches, even if already configured' f
+ DEFINE_boolean defaults false 'use default branch naming conventions' d
parse_args "$@"
-
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then
- git init
+ git_do init
else
# assure that we are not working in a repo with local changes
git_repo_is_headless || require_clean_working_tree
@@ -44,6 +69,10 @@ cmd_default() {
local branch_count
local answer
+ if flag defaults; then
+ warn "Using default branch names."
+ fi
+
# add a master branch if no such branch exists yet
local master_branch
if gitflow_has_master_configured && ! flag force; then
@@ -61,7 +90,7 @@ cmd_default() {
if [ "$branch_count" -eq 0 ]; then
echo "No branches exist yet. Base branches must be created now."
should_check_existence=NO
- default_suggestion=master
+ default_suggestion=$(git config --get gitflow.branch.master || echo master)
else
echo
echo "Which branch should be used for bringing forth production releases?"
@@ -69,26 +98,37 @@ cmd_default() {
should_check_existence=YES
default_suggestion=
- for guess in 'production' 'main' 'master'; do
+ for guess in $(git config --get gitflow.branch.master) \
+ 'production' 'main' 'master'; do
if git_local_branch_exists "$guess"; then
default_suggestion="$guess"
break
fi
done
fi
-
- echo "Branch name for production releases: [$default_suggestion] \c"
- read answer
+
+ printf "Branch name for production releases: [$default_suggestion] "
+ if noflag defaults; then
+ read answer
+ else
+ printf "\n"
+ fi
master_branch=${answer:-$default_suggestion}
# check existence in case of an already existing repo
if [ "$should_check_existence" = "YES" ]; then
- git_local_branch_exists "$master_branch" || \
+ # if no local branch exists and a remote branch of the same
+ # name exists, checkout that branch and use it for master
+ if ! git_local_branch_exists "$master_branch" && \
+ git_remote_branch_exists "origin/$master_branch"; then
+ git_do branch "$master_branch" "origin/$master_branch" >/dev/null 2>&1
+ elif ! git_local_branch_exists "$master_branch"; then
die "Local branch '$master_branch' does not exist."
+ fi
fi
# store the name of the master branch
- git config gitflow.branch.master "$master_branch"
+ git_do config gitflow.branch.master "$master_branch"
fi
# add a develop branch if no such branch exists yet
@@ -103,7 +143,7 @@ cmd_default() {
branch_count=$(git_local_branches | grep -v "^${master_branch}\$" | wc -l)
if [ "$branch_count" -eq 0 ]; then
should_check_existence=NO
- default_suggestion=develop
+ default_suggestion=$(git config --get gitflow.branch.develop || echo develop)
else
echo
echo "Which branch should be used for integration of the \"next release\"?"
@@ -111,16 +151,27 @@ cmd_default() {
should_check_existence=YES
default_suggestion=
- for guess in 'develop' 'int' 'integration' 'master'; do
- if git_local_branch_exists "$guess"; then
+ for guess in $(git config --get gitflow.branch.develop) \
+ 'develop' 'int' 'integration' 'master'; do
+ if git_local_branch_exists "$guess" && [ "$guess" != "$master_branch" ]; then
default_suggestion="$guess"
break
fi
done
+
+ if [ -z $default_suggestion ]; then
+ should_check_existence=NO
+ default_suggestion=$(git config --get gitflow.branch.develop || echo develop)
+ fi
+
fi
- echo "Branch name for \"next release\" development: [$default_suggestion] \c"
- read answer
+ printf "Branch name for \"next release\" development: [$default_suggestion] "
+ if noflag defaults; then
+ read answer
+ else
+ printf "\n"
+ fi
develop_branch=${answer:-$default_suggestion}
if [ "$master_branch" = "$develop_branch" ]; then
@@ -134,7 +185,7 @@ cmd_default() {
fi
# store the name of the develop branch
- git config gitflow.branch.develop "$develop_branch"
+ git_do config gitflow.branch.develop "$develop_branch"
fi
# Creation of HEAD
@@ -143,8 +194,8 @@ cmd_default() {
# it to be able to create new branches.
local created_gitflow_branch=0
if ! git rev-parse --quiet --verify HEAD >/dev/null 2>&1; then
- git symbolic-ref HEAD "refs/heads/$master_branch"
- git commit --allow-empty --quiet -m "Initial commit"
+ git_do symbolic-ref HEAD "refs/heads/$master_branch"
+ git_do commit --allow-empty --quiet -m "Initial commit"
created_gitflow_branch=1
fi
@@ -161,7 +212,11 @@ cmd_default() {
# default production branch and develop was "created". We should create
# the develop branch now in that case (we base it on master, of course)
if ! git_local_branch_exists "$develop_branch"; then
- git branch "$develop_branch" "$master_branch"
+ if git_remote_branch_exists "origin/$develop_branch"; then
+ git_do branch "$develop_branch" "origin/$develop_branch" >/dev/null 2>&1
+ else
+ git_do branch --no-track "$develop_branch" "$master_branch"
+ fi
created_gitflow_branch=1
fi
@@ -170,61 +225,88 @@ cmd_default() {
# switch to develop branch if its newly created
if [ $created_gitflow_branch -eq 1 ]; then
- git checkout -q "$develop_branch"
+ git_do checkout -q "$develop_branch"
fi
# finally, ask the user for naming conventions (branch and tag prefixes)
- echo
- echo "How to name your supporting branch prefixes?"
+ if flag force || \
+ ! git config --get gitflow.prefix.feature >/dev/null 2>&1 ||
+ ! git config --get gitflow.prefix.release >/dev/null 2>&1 ||
+ ! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 ||
+ ! git config --get gitflow.prefix.support >/dev/null 2>&1 ||
+ ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1; then
+ echo
+ echo "How to name your supporting branch prefixes?"
+ fi
local prefix
# Feature branches
if ! git config --get gitflow.prefix.feature >/dev/null 2>&1 || flag force; then
default_suggestion=$(git config --get gitflow.prefix.feature || echo feature/)
- echo "Feature branches? [$default_suggestion] \c"
- read answer
+ printf "Feature branches? [$default_suggestion] "
+ if noflag defaults; then
+ read answer
+ else
+ printf "\n"
+ fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.feature "$prefix"
+ git_do config gitflow.prefix.feature "$prefix"
fi
# Release branches
if ! git config --get gitflow.prefix.release >/dev/null 2>&1 || flag force; then
default_suggestion=$(git config --get gitflow.prefix.release || echo release/)
- echo "Release branches? [$default_suggestion] \c"
- read answer
+ printf "Release branches? [$default_suggestion] "
+ if noflag defaults; then
+ read answer
+ else
+ printf "\n"
+ fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.release "$prefix"
+ git_do config gitflow.prefix.release "$prefix"
fi
# Hotfix branches
if ! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 || flag force; then
default_suggestion=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
- echo "Hotfix branches? [$default_suggestion] \c"
- read answer
+ printf "Hotfix branches? [$default_suggestion] "
+ if noflag defaults; then
+ read answer
+ else
+ printf "\n"
+ fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.hotfix "$prefix"
+ git_do config gitflow.prefix.hotfix "$prefix"
fi
# Support branches
if ! git config --get gitflow.prefix.support >/dev/null 2>&1 || flag force; then
default_suggestion=$(git config --get gitflow.prefix.support || echo support/)
- echo "Support branches? [$default_suggestion] \c"
- read answer
+ printf "Support branches? [$default_suggestion] "
+ if noflag defaults; then
+ read answer
+ else
+ printf "\n"
+ fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.support "$prefix"
+ git_do config gitflow.prefix.support "$prefix"
fi
# Version tag prefix
if ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1 || flag force; then
default_suggestion=$(git config --get gitflow.prefix.versiontag || echo "")
- echo "Version tag prefix? [$default_suggestion] \c"
- read answer
+ printf "Version tag prefix? [$default_suggestion] "
+ if noflag defaults; then
+ read answer
+ else
+ printf "\n"
+ fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
- git config gitflow.prefix.versiontag "$prefix"
+ git_do config gitflow.prefix.versiontag "$prefix"
fi
diff --git a/git-flow-release b/git-flow-release
index 2a46a7aa9..cb95bd486 100644
--- a/git-flow-release
+++ b/git-flow-release
@@ -3,25 +3,53 @@
# repository operations for Vincent Driessen's branching model.
#
# Original blog post presenting this model is found at:
-# http://nvie.com/archives/323
+# http://nvie.com/git-model
#
# Feel free to contribute to this project at:
# http://github.com/nvie/gitflow
#
-# Copyright (c) 2010 by Vincent Driessen
-# Copyright (c) 2010 by Benedikt Böhm
+# Copyright 2010 Vincent Driessen. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of Vincent Driessen.
#
-require_git_repo
-require_gitflow_initialized
-gitflow_load_settings
-VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
-PREFIX=$(git config --get gitflow.prefix.release)
+init() {
+ require_git_repo
+ require_gitflow_initialized
+ gitflow_load_settings
+ VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
+ PREFIX=$(git config --get gitflow.prefix.release)
+}
usage() {
echo "usage: git flow release [list] [-v]"
- echo " git flow release start [-F] "
- echo " git flow release finish [-Fsump] "
+ echo " git flow release start [-F] []"
+ echo " git flow release finish [-FsumpkS] "
+ echo " git flow release publish "
+ echo " git flow release track "
}
cmd_default() {
@@ -38,10 +66,15 @@ cmd_list() {
release_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX")
if [ -z "$release_branches" ]; then
warn "No release branches exist."
+ warn ""
+ warn "You can start a new release branch:"
+ warn ""
+ warn " git flow release start []"
+ warn ""
exit 0
fi
- current_branch=$(git branch | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
+ current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
short_names=$(echo "$release_branches" | sed "s ^$PREFIX g")
# determine column width first
@@ -103,7 +136,7 @@ require_version_arg() {
}
require_base_is_on_develop() {
- if ! git branch --contains "$BASE" 2>/dev/null \
+ if ! git_do branch --no-color --contains "$BASE" 2>/dev/null \
| sed 's/[* ] //g' \
| grep -q "^$DEVELOP_BRANCH\$"; then
die "fatal: Given base '$BASE' is not a valid commit on '$DEVELOP_BRANCH'."
@@ -119,7 +152,7 @@ require_no_existing_release_branches() {
}
cmd_start() {
- DEFINE_boolean fetch true "fetch from $ORIGIN before performing finish" F
+ DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
parse_args "$@"
BASE=${2:-$DEVELOP_BRANCH}
require_version_arg
@@ -131,12 +164,14 @@ cmd_start() {
require_branch_absent "$BRANCH"
require_tag_absent "$VERSION_PREFIX$VERSION"
if flag fetch; then
- git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
+ git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
+ fi
+ if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then
+ require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
fi
- require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
# create branch
- git checkout -b "$BRANCH" "$BASE"
+ git_do checkout -b "$BRANCH" "$BASE"
echo
echo "Summary of actions:"
@@ -153,11 +188,15 @@ cmd_start() {
}
cmd_finish() {
- DEFINE_boolean fetch true "fetch from $ORIGIN before performing finish" F
+ DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
DEFINE_boolean sign false "sign the release tag cryptographically" s
DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u
DEFINE_string message "" "use the given tag message" m
+ DEFINE_string messagefile "" "use the contents of the given file as a tag message" f
DEFINE_boolean push false "push to $ORIGIN after performing finish" p
+ DEFINE_boolean keep false "keep branch after performing finish" k
+ DEFINE_boolean notag false "don't tag this release" n
+ DEFINE_boolean squash false "squash release during merge" S
parse_args "$@"
require_version_arg
@@ -171,73 +210,156 @@ cmd_finish() {
require_branch "$BRANCH"
require_clean_working_tree
if flag fetch; then
- git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
+ git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not fetch $MASTER_BRANCH from $ORIGIN."
- git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
+ git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not fetch $DEVELOP_BRANCH from $ORIGIN."
fi
- require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
- require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
+ require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
+ fi
+ if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then
+ require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
+ fi
# try to merge into master
# in case a previous attempt to finish this release branch has failed,
# but the merge into master was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
- git checkout "$MASTER_BRANCH" || \
+ git_do checkout "$MASTER_BRANCH" || \
die "Could not check out $MASTER_BRANCH."
- git merge --no-ff "$BRANCH" || \
- die "There were merge conflicts."
- # TODO: What do we do now?
+ if noflag squash; then
+ git_do merge --no-ff "$BRANCH" || \
+ die "There were merge conflicts."
+ # TODO: What do we do now?
+ else
+ git_do merge --squash "$BRANCH" || \
+ die "There were merge conflicts."
+ git_do commit
+ fi
fi
- # try to tag the release
- # in case a previous attempt to finish this release branch has failed,
- # but the tag was set successful, we skip it now
- local tagname=$VERSION_PREFIX$VERSION
- if ! git_tag_exists "$tagname"; then
- local opts="-a"
- flag sign && opts="$opts -s"
- [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
- [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
- git tag $opts "$tagname" || \
- die "Tagging failed. Please run finish again to retry."
+ if noflag notag; then
+ # try to tag the release
+ # in case a previous attempt to finish this release branch has failed,
+ # but the tag was set successful, we skip it now
+ local tagname=$VERSION_PREFIX$VERSION
+ if ! git_tag_exists "$tagname"; then
+ local opts="-a"
+ flag sign && opts="$opts -s"
+ [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
+ [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
+ [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
+ eval git_do tag $opts "$tagname" "$BRANCH" || \
+ die "Tagging failed. Please run finish again to retry."
+ fi
fi
# try to merge into develop
# in case a previous attempt to finish this release branch has failed,
# but the merge into develop was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
- git checkout "$DEVELOP_BRANCH" || \
+ git_do checkout "$DEVELOP_BRANCH" || \
die "Could not check out $DEVELOP_BRANCH."
# TODO: Actually, accounting for 'git describe' pays, so we should
# ideally git merge --no-ff $tagname here, instead!
- git merge --no-ff "$BRANCH" || \
- die "There were merge conflicts."
- # TODO: What do we do now?
+ if noflag squash; then
+ git_do merge --no-ff "$BRANCH" || \
+ die "There were merge conflicts."
+ # TODO: What do we do now?
+ else
+ git_do merge --squash "$BRANCH" || \
+ die "There were merge conflicts."
+ # TODO: What do we do now?
+ git_do commit
+ fi
fi
# delete branch
- git branch -d "$BRANCH"
+ if noflag keep; then
+ if [ "$BRANCH" = "$(git_current_branch)" ]; then
+ git_do checkout "$MASTER_BRANCH"
+ fi
+ git_do branch -d "$BRANCH"
+ fi
if flag push; then
- git push "$ORIGIN" "$DEVELOP_BRANCH" || \
+ git_do push "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not push to $DEVELOP_BRANCH from $ORIGIN."
- git push "$ORIGIN" "$MASTER_BRANCH" || \
+ git_do push "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not push to $MASTER_BRANCH from $ORIGIN."
- git push --tags "$ORIGIN" || \
- die "Could not push tags to $ORIGIN."
+ if noflag notag; then
+ git_do push --tags "$ORIGIN" || \
+ die "Could not push tags to $ORIGIN."
+ fi
+ git_do push "$ORIGIN" :"$BRANCH" || \
+ die "Could not delete the remote $BRANCH in $ORIGIN."
fi
echo
echo "Summary of actions:"
echo "- Latest objects have been fetched from '$ORIGIN'"
echo "- Release branch has been merged into '$MASTER_BRANCH'"
- echo "- The release was tagged '$tagname'"
+ if noflag notag; then
+ echo "- The release was tagged '$tagname'"
+ fi
echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'"
- echo "- Release branch '$BRANCH' has been deleted"
+ if flag keep; then
+ echo "- Release branch '$BRANCH' is still available"
+ else
+ echo "- Release branch '$BRANCH' has been deleted"
+ fi
if flag push; then
echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'"
+ echo "- Release branch '$BRANCH' in '$ORIGIN' has been deleted."
fi
echo
}
+
+cmd_publish() {
+ parse_args "$@"
+ require_version_arg
+
+ # sanity checks
+ require_clean_working_tree
+ require_branch "$BRANCH"
+ git_do fetch -q "$ORIGIN"
+ require_branch_absent "$ORIGIN/$BRANCH"
+
+ # create remote branch
+ git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
+ git_do fetch -q "$ORIGIN"
+
+ # configure remote tracking
+ git_do config "branch.$BRANCH.remote" "$ORIGIN"
+ git_do config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
+ git_do checkout "$BRANCH"
+
+ echo
+ echo "Summary of actions:"
+ echo "- A new remote branch '$BRANCH' was created"
+ echo "- The local branch '$BRANCH' was configured to track the remote branch"
+ echo "- You are now on branch '$BRANCH'"
+ echo
+}
+
+cmd_track() {
+ parse_args "$@"
+ require_version_arg
+
+ # sanity checks
+ require_clean_working_tree
+ require_branch_absent "$BRANCH"
+ git_do fetch -q "$ORIGIN"
+ require_branch "$ORIGIN/$BRANCH"
+
+ # create tracking branch
+ git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
+
+ echo
+ echo "Summary of actions:"
+ echo "- A new remote tracking branch '$BRANCH' was created"
+ echo "- You are now on branch '$BRANCH'"
+ echo
+}
diff --git a/git-flow-support b/git-flow-support
index 9403c12c1..cdbfc717c 100644
--- a/git-flow-support
+++ b/git-flow-support
@@ -3,20 +3,46 @@
# repository operations for Vincent Driessen's branching model.
#
# Original blog post presenting this model is found at:
-# http://nvie.com/archives/323
+# http://nvie.com/git-model
#
# Feel free to contribute to this project at:
# http://github.com/nvie/gitflow
#
-# Copyright (c) 2010 by Vincent Driessen
-# Copyright (c) 2010 by Benedikt Böhm
+# Copyright 2010 Vincent Driessen. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of Vincent Driessen.
#
-require_git_repo
-require_gitflow_initialized
-gitflow_load_settings
-VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
-PREFIX=$(git config --get gitflow.prefix.support)
+init() {
+ require_git_repo
+ require_gitflow_initialized
+ gitflow_load_settings
+ VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`")
+ PREFIX=$(git config --get gitflow.prefix.support)
+}
warn "note: The support subcommand is still very EXPERIMENTAL!"
warn "note: DO NOT use it in a production situation."
@@ -40,9 +66,14 @@ cmd_list() {
support_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX")
if [ -z "$support_branches" ]; then
warn "No support branches exist."
+ warn ""
+ warn "You can start a new support branch:"
+ warn ""
+ warn " git flow support start "
+ warn ""
exit 0
fi
- current_branch=$(git branch | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
+ current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g')
short_names=$(echo "$support_branches" | sed "s ^$PREFIX g")
# determine column width first
@@ -119,7 +150,7 @@ require_base_arg() {
}
require_base_is_on_master() {
- if ! git branch --contains "$BASE" 2>/dev/null \
+ if ! git branch --no-color --contains "$BASE" 2>/dev/null \
| sed 's/[* ] //g' \
| grep -q "^$MASTER_BRANCH\$"; then
die "fatal: Given base '$BASE' is not a valid commit on '$MASTER_BRANCH'."
@@ -127,7 +158,7 @@ require_base_is_on_master() {
}
cmd_start() {
- DEFINE_boolean fetch true "fetch from $ORIGIN before performing finish" F
+ DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F
parse_args "$@"
require_version_arg
require_base_arg
@@ -138,12 +169,12 @@ cmd_start() {
# fetch remote changes
if flag fetch; then
- git fetch -q "$ORIGIN" "$BASE"
+ git_do fetch -q "$ORIGIN" "$BASE"
fi
require_branch_absent "$BRANCH"
# create branch
- git checkout -b "$BRANCH" "$BASE"
+ git_do checkout -b "$BRANCH" "$BASE"
echo
echo "Summary of actions:"
diff --git a/git-flow-version b/git-flow-version
index cd5bb456b..8c314996c 100644
--- a/git-flow-version
+++ b/git-flow-version
@@ -3,15 +3,40 @@
# repository operations for Vincent Driessen's branching model.
#
# Original blog post presenting this model is found at:
-# http://nvie.com/archives/323
+# http://nvie.com/git-model
#
# Feel free to contribute to this project at:
# http://github.com/nvie/gitflow
#
-# Copyright (c) 2010 by Vincent Driessen
-# Copyright (c) 2010 by Benedikt Böhm
+# Copyright 2010 Vincent Driessen. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of Vincent Driessen.
#
-GITFLOW_VERSION=0.2
+
+GITFLOW_VERSION=0.4.2-pre
usage() {
echo "usage: git flow version"
diff --git a/gitflow-common b/gitflow-common
index aa337007c..332740533 100644
--- a/gitflow-common
+++ b/gitflow-common
@@ -3,13 +3,37 @@
# repository operations for Vincent Driessen's branching model.
#
# Original blog post presenting this model is found at:
-# http://nvie.com/archives/323
+# http://nvie.com/git-model
#
# Feel free to contribute to this project at:
# http://github.com/nvie/gitflow
#
-# Copyright (c) 2010 by Vincent Driessen
-# Copyright (c) 2010 by Benedikt Böhm
+# Copyright 2010 Vincent Driessen. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of Vincent Driessen.
#
#
@@ -20,10 +44,14 @@
warn() { echo "$@" >&2; }
die() { warn "$@"; exit 1; }
+escape() {
+ echo "$1" | sed 's/\([\.\$\*]\)/\\\1/g'
+}
+
# set logic
has() {
local item=$1; shift
- echo " $@ " | grep -q " $item "
+ echo " $@ " | grep -q " $(escape $item) "
}
# basic math
@@ -42,13 +70,21 @@ noflag() { local FLAG; eval FLAG='$FLAGS_'$1; [ $FLAG -ne $FLAGS_TRUE ]; }
# Git specific common functionality
#
-git_local_branches() { git branch | sed 's/^[* ] //'; }
-git_remote_branches() { git branch -r | sed 's/^[* ] //'; }
-git_all_branches() { ( git branch; git branch -r) | sed 's/^[* ] //'; }
+git_do() {
+ # equivalent to git, used to indicate actions that make modifications
+ if flag show_commands; then
+ echo "git $@" >&2
+ fi
+ git "$@"
+}
+
+git_local_branches() { git branch --no-color | sed 's/^[* ] //'; }
+git_remote_branches() { git branch -r --no-color | sed 's/^[* ] //'; }
+git_all_branches() { ( git branch --no-color; git branch -r --no-color) | sed 's/^[* ] //'; }
git_all_tags() { git tag; }
git_current_branch() {
- git branch | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g'
+ git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g'
}
git_is_clean_working_tree() {
@@ -69,6 +105,10 @@ git_local_branch_exists() {
has $1 $(git_local_branches)
}
+git_remote_branch_exists() {
+ has $1 $(git_remote_branches)
+}
+
git_branch_exists() {
has $1 $(git_all_branches)
}
@@ -116,7 +156,7 @@ git_compare_branches() {
git_is_branch_merged_into() {
local subject=$1
local base=$2
- local all_merges=$(git branch --contains $subject | sed 's/^[* ] //')
+ local all_merges="$(git branch --no-color --contains $subject | sed 's/^[* ] //')"
has $base $all_merges
}
@@ -153,7 +193,7 @@ gitflow_is_initialized() {
# loading settings that can be overridden using git config
gitflow_load_settings() {
- export DOT_GIT_DIR=$(git rev-parse --git-dir >/dev/null 2>&1)
+ export DOT_GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
export MASTER_BRANCH=$(git config --get gitflow.branch.master)
export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop)
export ORIGIN=$(git config --get gitflow.origin || echo origin)
@@ -182,12 +222,12 @@ gitflow_resolve_nameprefix() {
local num_matches
# first, check if there is a perfect match
- if has "$(git_local_branches)" "$prefix$name"; then
+ if git_local_branch_exists "$prefix$name"; then
echo "$name"
return 0
fi
- matches=$(echo "$(git_local_branches)" | grep "^$prefix$name")
+ matches=$(echo "$(git_local_branches)" | grep "^$(escape "$prefix$name")")
num_matches=$(echo "$matches" | wc -l)
if [ -z "$matches" ]; then
# no prefix match, so take it literally
@@ -260,9 +300,11 @@ require_branch_absent() {
}
require_tag_absent() {
- if has $1 $(git_all_tags); then
- die "Tag '$1' already exists. Pick another name."
- fi
+ for tag in $(git_all_tags); do
+ if [ "$1" = "$tag" ]; then
+ die "Tag '$1' already exists. Pick another name."
+ fi
+ done
}
require_branches_equal() {