diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..9de970d --- /dev/null +++ b/AUTHORS @@ -0,0 +1,11 @@ +Authors are (ordered by first commit date): + +- Vincent Driessen +- Benedikt Böhm +- Daniel Truemper +- Jason L. Shiffer +- Randy Merrill +- Rick Osborne +- Mark Derricutt + +Portions derived from other open source works are clearly marked. diff --git a/Changes.mdown b/Changes.mdown new file mode 100644 index 0000000..c7b92c8 --- /dev/null +++ b/Changes.mdown @@ -0,0 +1,50 @@ +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 0000000..cedd182 --- /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 bb1117e..6f82544 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,31 @@ +# +# 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 diff --git a/README.mdown b/README.mdown index aabdb4d..35bd90a 100644 --- a/README.mdown +++ b/README.mdown @@ -5,13 +5,14 @@ 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 ------------------- +The easiest way to install git-flow is using Rick Osborne's excellent +git-flow installer, which can be run using the following command: + + $ wget -q -O - http://github.com/nvie/gitflow/raw/develop/contrib/gitflow-installer.sh | sudo sh + +If you prefer a manual installation, please use the following instructions. After downloading the sources from Github, also fetch the submodules: $ git submodule init @@ -30,6 +31,21 @@ 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/) 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. + +If you are a [zsh](http://www.zsh.org) user with some plugin-writing +experience, please help us develop a +[completion plugin](http://github.com/bobthecow/git-flow-completion/issues#issue/1) +for zsh, too. Please contact me on [Github](http://github.com/inbox/new/nvie) +or [Twitter](http://twitter.com/nvie) to discuss details. + + Please help out --------------- This project is still under development. Feedback and suggestions are very @@ -37,7 +53,20 @@ welcome and I encourage you to use the [Issues list](http://github.com/nvie/gitflow/issues) on Github to provide that feedback. -Feel free to fork this repo and to commit your additions. +Feel free to fork this repo and to commit your additions. For a list of all +contributors, please see the [AUTHORS](AUTHORS) file. + +Any questions, tips, or general discussion can be posted to our Google group: +http://groups.google.com/group/gitflow-users + + +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: diff --git a/contrib/gitflow-installer.sh b/contrib/gitflow-installer.sh new file mode 100644 index 0000000..33dbe58 --- /dev/null +++ b/contrib/gitflow-installer.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +# 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" && -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/git-flow b/git-flow index 84adc05..e95d4ad 100755 --- a/git-flow +++ b/git-flow @@ -4,13 +4,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. # # enable debug mode @@ -78,11 +102,4 @@ main() { 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 d8d4bb7..2fdba25 100644 --- a/git-flow-feature +++ b/git-flow-feature @@ -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. # require_git_repo @@ -19,12 +43,14 @@ 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 start [-F] []" echo " git flow feature finish [-rF] " 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 []" } cmd_default() { @@ -41,6 +67,11 @@ 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') @@ -112,45 +143,63 @@ 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 } -parse_args() { +name_or_current() { + if [ -z "$NAME" ]; then + use_current_feature_branch_name + fi +} + +parse_cmdline() { # parse options FLAGS "$@" || exit $? eval set -- "${FLAGS_ARGV}" +} + +parse_args() { + parse_cmdline "$@" # read arguments into global variables NAME=$1 BRANCH=$PREFIX$NAME } +parse_remote_name() { + parse_cmdline "$@" + + # 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 @@ -158,7 +207,11 @@ cmd_start() { git 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 @@ -172,7 +225,7 @@ 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 } @@ -229,14 +282,18 @@ 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 fetch -q "$ORIGIN" "$BRANCH" + fi fi 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 @@ -286,7 +343,7 @@ helper_finish_cleanup() { if flag fetch; then git push "$ORIGIN" ":refs/heads/$BRANCH" fi - git branch -d "$BRANCH" + git branch -D "$BRANCH" echo echo "Summary of actions:" @@ -361,6 +418,22 @@ cmd_diff() { fi } +cmd_checkout() { + parse_args "$@" + + if [ "$NAME" != "" ]; then + expand_nameprefix_arg + git 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 "$@" @@ -376,3 +449,51 @@ cmd_rebase() { fi git 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 + 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 + git pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'." + echo "Pulled $REMOTE's changes into $BRANCH." + else + # setup the local branch clone for the first time + git fetch -q "$REMOTE" "$BRANCH" || die "Fetch failed." # stores in FETCH_HEAD + git branch --no-track "$BRANCH" FETCH_HEAD || die "Branch failed." + git 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 5866178..390e537 100644 --- a/git-flow-hotfix +++ b/git-flow-hotfix @@ -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. # require_git_repo @@ -38,6 +62,11 @@ 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') @@ -124,7 +153,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 @@ -138,7 +167,9 @@ cmd_start() { if flag fetch; then git fetch -q "$ORIGIN" "$MASTER_BRANCH" fi - require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" + if has "$ORIGIN/$MASTER_BRANCH" "$(git_remote_branches)"; then + require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" + fi # create branch git checkout -b "$BRANCH" "$BASE" @@ -158,7 +189,7 @@ 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 @@ -180,8 +211,12 @@ cmd_finish() { git 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, diff --git a/git-flow-init b/git-flow-init index ffc9e96..461ee8c 100644 --- a/git-flow-init +++ b/git-flow-init @@ -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. # usage() { @@ -61,7 +85,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,7 +93,8 @@ 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 @@ -77,7 +102,7 @@ cmd_default() { done fi - echo "Branch name for production releases: [$default_suggestion] \c" + printf "Branch name for production releases: [$default_suggestion] " read answer master_branch=${answer:-$default_suggestion} @@ -103,7 +128,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,7 +136,8 @@ cmd_default() { should_check_existence=YES default_suggestion= - for guess in 'develop' 'int' 'integration' 'master'; do + for guess in $(git config --get gitflow.branch.develop) \ + 'develop' 'int' 'integration' 'master'; do if git_local_branch_exists "$guess"; then default_suggestion="$guess" break @@ -119,7 +145,7 @@ cmd_default() { done fi - echo "Branch name for \"next release\" development: [$default_suggestion] \c" + printf "Branch name for \"next release\" development: [$default_suggestion] " read answer develop_branch=${answer:-$default_suggestion} @@ -161,7 +187,7 @@ 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" + git branch --no-track "$develop_branch" "$master_branch" created_gitflow_branch=1 fi @@ -174,15 +200,22 @@ cmd_default() { 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" + printf "Feature branches? [$default_suggestion] " read answer [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} git config gitflow.prefix.feature "$prefix" @@ -191,7 +224,7 @@ cmd_default() { # 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" + printf "Release branches? [$default_suggestion] " read answer [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} git config gitflow.prefix.release "$prefix" @@ -201,7 +234,7 @@ cmd_default() { # 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" + printf "Hotfix branches? [$default_suggestion] " read answer [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} git config gitflow.prefix.hotfix "$prefix" @@ -211,7 +244,7 @@ cmd_default() { # 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" + printf "Support branches? [$default_suggestion] " read answer [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} git config gitflow.prefix.support "$prefix" @@ -221,7 +254,7 @@ cmd_default() { # 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" + printf "Version tag prefix? [$default_suggestion] " read answer [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} git config gitflow.prefix.versiontag "$prefix" diff --git a/git-flow-release b/git-flow-release index 2a46a7a..b998673 100644 --- a/git-flow-release +++ b/git-flow-release @@ -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. # require_git_repo @@ -38,6 +62,11 @@ 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 @@ -119,7 +148,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 @@ -133,7 +162,9 @@ cmd_start() { if flag fetch; then git fetch -q "$ORIGIN" "$DEVELOP_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 # create branch git checkout -b "$BRANCH" "$BASE" @@ -153,7 +184,7 @@ 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 @@ -176,8 +207,12 @@ cmd_finish() { git 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, diff --git a/git-flow-support b/git-flow-support index 9403c12..ba92cb9 100644 --- a/git-flow-support +++ b/git-flow-support @@ -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. # require_git_repo @@ -40,6 +64,11 @@ 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') @@ -127,7 +156,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 diff --git a/git-flow-version b/git-flow-version index 347e6f4..7371595 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.1 + +GITFLOW_VERSION=0.3 usage() { echo "usage: git flow version" diff --git a/gitflow-common b/gitflow-common index aa33700..29ef388 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. # # @@ -182,7 +206,7 @@ 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