Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 1 | # |
| 2 | # git-flow -- A collection of Git extensions to provide high-level |
| 3 | # repository operations for Vincent Driessen's branching model. |
| 4 | # |
| 5 | # Original blog post presenting this model is found at: |
Vincent Driessen | ddb350b | 2010-07-09 09:42:09 +0200 | [diff] [blame] | 6 | # http://nvie.com/git-model |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 7 | # |
| 8 | # Feel free to contribute to this project at: |
| 9 | # http://github.com/nvie/gitflow |
| 10 | # |
Vincent Driessen | d72acba | 2010-04-04 16:10:17 +0200 | [diff] [blame] | 11 | # Copyright 2010 Vincent Driessen. All rights reserved. |
| 12 | # |
| 13 | # Redistribution and use in source and binary forms, with or without |
| 14 | # modification, are permitted provided that the following conditions are met: |
| 15 | # |
| 16 | # 1. Redistributions of source code must retain the above copyright notice, |
| 17 | # this list of conditions and the following disclaimer. |
| 18 | # |
| 19 | # 2. Redistributions in binary form must reproduce the above copyright |
| 20 | # notice, this list of conditions and the following disclaimer in the |
| 21 | # documentation and/or other materials provided with the distribution. |
| 22 | # |
| 23 | # THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR |
| 24 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 25 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 26 | # EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 27 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 28 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 29 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 30 | # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 31 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
| 32 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | # |
| 34 | # The views and conclusions contained in the software and documentation are |
| 35 | # those of the authors and should not be interpreted as representing official |
| 36 | # policies, either expressed or implied, of Vincent Driessen. |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 37 | # |
| 38 | |
| 39 | usage() { |
Vincent Driessen | 5f860bf | 2011-02-05 08:22:38 +0100 | [diff] [blame] | 40 | echo "usage: git flow init [-fd]" |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 41 | } |
| 42 | |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 43 | parse_args() { |
| 44 | # parse options |
| 45 | FLAGS "$@" || exit $? |
| 46 | eval set -- "${FLAGS_ARGV}" |
| 47 | } |
| 48 | |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 49 | # Default entry when no SUBACTION is given |
| 50 | cmd_default() { |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 51 | DEFINE_boolean force false 'force setting of gitflow branches, even if already configured' f |
Vincent Driessen | 5f860bf | 2011-02-05 08:22:38 +0100 | [diff] [blame] | 52 | DEFINE_boolean defaults false 'use default branch naming conventions' d |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 53 | parse_args "$@" |
Joseph A. Levin | d2eccaa | 2011-02-04 21:30:15 -0600 | [diff] [blame] | 54 | |
Vincent Driessen | 283b0f7 | 2010-02-15 23:23:14 +0100 | [diff] [blame] | 55 | if ! git rev-parse --git-dir >/dev/null 2>&1; then |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 56 | git init |
| 57 | else |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 58 | # assure that we are not working in a repo with local changes |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 59 | git_repo_is_headless || require_clean_working_tree |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 60 | fi |
| 61 | |
| 62 | # running git flow init on an already initialized repo is fine |
| 63 | if gitflow_is_initialized && ! flag force; then |
| 64 | warn "Already initialized for gitflow." |
| 65 | warn "To force reinitialization, use: git flow init -f" |
| 66 | exit 0 |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 67 | fi |
| 68 | |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 69 | local branch_count |
Vincent Driessen | f476d26 | 2010-02-20 16:23:47 +0100 | [diff] [blame] | 70 | local answer |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 71 | |
Vincent Driessen | f78b660 | 2011-02-14 07:39:23 +0100 | [diff] [blame] | 72 | if flag defaults; then |
| 73 | warn "Using default branch names." |
| 74 | fi |
| 75 | |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 76 | # add a master branch if no such branch exists yet |
| 77 | local master_branch |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 78 | if gitflow_has_master_configured && ! flag force; then |
| 79 | master_branch=$(git config --get gitflow.branch.master) |
| 80 | else |
| 81 | # Two cases are distinguished: |
| 82 | # 1. A fresh git repo (without any branches) |
| 83 | # We will create a new master/develop branch for the user |
| 84 | # 2. Some branches do already exist |
| 85 | # We will disallow creation of new master/develop branches and |
| 86 | # rather allow to use existing branches for git-flow. |
| 87 | local default_suggestion |
| 88 | local should_check_existence |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 89 | branch_count=$(git_local_branches | wc -l) |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 90 | if [ "$branch_count" -eq 0 ]; then |
| 91 | echo "No branches exist yet. Base branches must be created now." |
| 92 | should_check_existence=NO |
Vincent Driessen | b1033aa | 2010-03-23 21:10:13 +0100 | [diff] [blame] | 93 | default_suggestion=$(git config --get gitflow.branch.master || echo master) |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 94 | else |
| 95 | echo |
| 96 | echo "Which branch should be used for bringing forth production releases?" |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 97 | git_local_branches | sed 's/^.*$/ - &/g' |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 98 | |
| 99 | should_check_existence=YES |
| 100 | default_suggestion= |
Vincent Driessen | b1033aa | 2010-03-23 21:10:13 +0100 | [diff] [blame] | 101 | for guess in $(git config --get gitflow.branch.master) \ |
| 102 | 'production' 'main' 'master'; do |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 103 | if git_local_branch_exists "$guess"; then |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 104 | default_suggestion="$guess" |
| 105 | break |
| 106 | fi |
| 107 | done |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 108 | fi |
Joseph A. Levin | d2eccaa | 2011-02-04 21:30:15 -0600 | [diff] [blame] | 109 | |
Vincent Driessen | f6228ed | 2010-03-23 21:19:54 +0100 | [diff] [blame] | 110 | printf "Branch name for production releases: [$default_suggestion] " |
Vincent Driessen | 5f860bf | 2011-02-05 08:22:38 +0100 | [diff] [blame] | 111 | if noflag defaults; then |
Joseph A. Levin | d2eccaa | 2011-02-04 21:30:15 -0600 | [diff] [blame] | 112 | read answer |
| 113 | else |
| 114 | printf "\n" |
| 115 | fi |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 116 | master_branch=${answer:-$default_suggestion} |
| 117 | |
| 118 | # check existence in case of an already existing repo |
| 119 | if [ "$should_check_existence" = "YES" ]; then |
Eric J. Holmes | baf163e | 2011-11-28 23:28:47 -0800 | [diff] [blame] | 120 | # if no local branch exists and a remote branch of the same |
| 121 | # name exists, checkout that branch and use it for master |
| 122 | if ! git_local_branch_exists "$master_branch" && \ |
| 123 | git_remote_branch_exists "origin/$master_branch"; then |
| 124 | git branch "$master_branch" "origin/$master_branch" >/dev/null 2>&1 |
| 125 | elif ! git_local_branch_exists "$master_branch"; then |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 126 | die "Local branch '$master_branch' does not exist." |
Eric J. Holmes | baf163e | 2011-11-28 23:28:47 -0800 | [diff] [blame] | 127 | fi |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 128 | fi |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 129 | |
Vincent Driessen | 6188206 | 2010-02-18 12:32:20 +0100 | [diff] [blame] | 130 | # store the name of the master branch |
| 131 | git config gitflow.branch.master "$master_branch" |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 132 | fi |
| 133 | |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 134 | # add a develop branch if no such branch exists yet |
| 135 | local develop_branch |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 136 | if gitflow_has_develop_configured && ! flag force; then |
| 137 | develop_branch=$(git config --get gitflow.branch.develop) |
| 138 | else |
| 139 | # Again, the same two cases as with the master selection are |
| 140 | # considered (fresh repo or repo that contains branches) |
| 141 | local default_suggestion |
| 142 | local should_check_existence |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 143 | branch_count=$(git_local_branches | grep -v "^${master_branch}\$" | wc -l) |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 144 | if [ "$branch_count" -eq 0 ]; then |
| 145 | should_check_existence=NO |
Vincent Driessen | b1033aa | 2010-03-23 21:10:13 +0100 | [diff] [blame] | 146 | default_suggestion=$(git config --get gitflow.branch.develop || echo develop) |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 147 | else |
| 148 | echo |
| 149 | echo "Which branch should be used for integration of the \"next release\"?" |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 150 | git_local_branches | grep -v "^${master_branch}\$" | sed 's/^.*$/ - &/g' |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 151 | |
| 152 | should_check_existence=YES |
| 153 | default_suggestion= |
Vincent Driessen | b1033aa | 2010-03-23 21:10:13 +0100 | [diff] [blame] | 154 | for guess in $(git config --get gitflow.branch.develop) \ |
| 155 | 'develop' 'int' 'integration' 'master'; do |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 156 | if git_local_branch_exists "$guess"; then |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 157 | default_suggestion="$guess" |
| 158 | break |
| 159 | fi |
| 160 | done |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 161 | fi |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 162 | |
Vincent Driessen | f6228ed | 2010-03-23 21:19:54 +0100 | [diff] [blame] | 163 | printf "Branch name for \"next release\" development: [$default_suggestion] " |
Vincent Driessen | 5f860bf | 2011-02-05 08:22:38 +0100 | [diff] [blame] | 164 | if noflag defaults; then |
Joseph A. Levin | d2eccaa | 2011-02-04 21:30:15 -0600 | [diff] [blame] | 165 | read answer |
| 166 | else |
| 167 | printf "\n" |
| 168 | fi |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 169 | develop_branch=${answer:-$default_suggestion} |
| 170 | |
| 171 | if [ "$master_branch" = "$develop_branch" ]; then |
| 172 | die "Production and integration branches should differ." |
| 173 | fi |
| 174 | |
| 175 | # check existence in case of an already existing repo |
| 176 | if [ "$should_check_existence" = "YES" ]; then |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 177 | git_local_branch_exists "$develop_branch" || \ |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 178 | die "Local branch '$develop_branch' does not exist." |
| 179 | fi |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 180 | |
Vincent Driessen | 6188206 | 2010-02-18 12:32:20 +0100 | [diff] [blame] | 181 | # store the name of the develop branch |
| 182 | git config gitflow.branch.develop "$develop_branch" |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 183 | fi |
| 184 | |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 185 | # Creation of HEAD |
| 186 | # ---------------- |
| 187 | # We create a HEAD now, if it does not exist yet (in a fresh repo). We need |
| 188 | # it to be able to create new branches. |
Vincent Driessen | 3227d80 | 2010-02-20 16:13:23 +0100 | [diff] [blame] | 189 | local created_gitflow_branch=0 |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 190 | if ! git rev-parse --quiet --verify HEAD >/dev/null 2>&1; then |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 191 | git symbolic-ref HEAD "refs/heads/$master_branch" |
Vincent Driessen | 6188206 | 2010-02-18 12:32:20 +0100 | [diff] [blame] | 192 | git commit --allow-empty --quiet -m "Initial commit" |
Vincent Driessen | 3227d80 | 2010-02-20 16:13:23 +0100 | [diff] [blame] | 193 | created_gitflow_branch=1 |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 194 | fi |
| 195 | |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 196 | # Creation of master |
| 197 | # ------------------ |
| 198 | # At this point, there always is a master branch: either it existed already |
| 199 | # (and was picked interactively as the production branch) or it has just |
| 200 | # been created in a fresh repo |
| 201 | |
| 202 | # Creation of develop |
| 203 | # ------------------- |
| 204 | # The develop branch possibly does not exist yet. This is the case when, |
| 205 | # in a git init'ed repo with one or more commits, master was picked as the |
| 206 | # default production branch and develop was "created". We should create |
| 207 | # the develop branch now in that case (we base it on master, of course) |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 208 | if ! git_local_branch_exists "$develop_branch"; then |
Emre Berge Ergenekon | 62c339e | 2011-11-27 22:07:57 -0800 | [diff] [blame] | 209 | if git_remote_branch_exists "origin/$develop_branch"; then |
| 210 | git branch "$develop_branch" "origin/$develop_branch" >/dev/null 2>&1 |
| 211 | else |
| 212 | git branch --no-track "$develop_branch" "$master_branch" |
| 213 | fi |
Vincent Driessen | 3227d80 | 2010-02-20 16:13:23 +0100 | [diff] [blame] | 214 | created_gitflow_branch=1 |
Vincent Driessen | 0161de5 | 2010-02-18 12:07:34 +0100 | [diff] [blame] | 215 | fi |
| 216 | |
Vincent Driessen | 131c298 | 2010-02-20 14:30:16 +0100 | [diff] [blame] | 217 | # assert the gitflow repo has been correctly initialized |
| 218 | gitflow_is_initialized |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 219 | |
Vincent Driessen | 3227d80 | 2010-02-20 16:13:23 +0100 | [diff] [blame] | 220 | # switch to develop branch if its newly created |
| 221 | if [ $created_gitflow_branch -eq 1 ]; then |
| 222 | git checkout -q "$develop_branch" |
| 223 | fi |
Vincent Driessen | 6188206 | 2010-02-18 12:32:20 +0100 | [diff] [blame] | 224 | |
Vincent Driessen | f476d26 | 2010-02-20 16:23:47 +0100 | [diff] [blame] | 225 | # finally, ask the user for naming conventions (branch and tag prefixes) |
Vincent Driessen | b1033aa | 2010-03-23 21:10:13 +0100 | [diff] [blame] | 226 | if flag force || \ |
| 227 | ! git config --get gitflow.prefix.feature >/dev/null 2>&1 || |
| 228 | ! git config --get gitflow.prefix.release >/dev/null 2>&1 || |
| 229 | ! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 || |
| 230 | ! git config --get gitflow.prefix.support >/dev/null 2>&1 || |
| 231 | ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1; then |
| 232 | echo |
| 233 | echo "How to name your supporting branch prefixes?" |
| 234 | fi |
Vincent Driessen | f476d26 | 2010-02-20 16:23:47 +0100 | [diff] [blame] | 235 | |
| 236 | local prefix |
| 237 | |
| 238 | # Feature branches |
Vincent Driessen | 1d8bb0d | 2010-02-20 16:46:38 +0100 | [diff] [blame] | 239 | if ! git config --get gitflow.prefix.feature >/dev/null 2>&1 || flag force; then |
| 240 | default_suggestion=$(git config --get gitflow.prefix.feature || echo feature/) |
Vincent Driessen | f6228ed | 2010-03-23 21:19:54 +0100 | [diff] [blame] | 241 | printf "Feature branches? [$default_suggestion] " |
Vincent Driessen | 5f860bf | 2011-02-05 08:22:38 +0100 | [diff] [blame] | 242 | if noflag defaults; then |
Joseph A. Levin | d2eccaa | 2011-02-04 21:30:15 -0600 | [diff] [blame] | 243 | read answer |
| 244 | else |
| 245 | printf "\n" |
| 246 | fi |
Vincent Driessen | 1d8bb0d | 2010-02-20 16:46:38 +0100 | [diff] [blame] | 247 | [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} |
| 248 | git config gitflow.prefix.feature "$prefix" |
| 249 | fi |
Vincent Driessen | f476d26 | 2010-02-20 16:23:47 +0100 | [diff] [blame] | 250 | |
| 251 | # Release branches |
Vincent Driessen | 1d8bb0d | 2010-02-20 16:46:38 +0100 | [diff] [blame] | 252 | if ! git config --get gitflow.prefix.release >/dev/null 2>&1 || flag force; then |
| 253 | default_suggestion=$(git config --get gitflow.prefix.release || echo release/) |
Vincent Driessen | f6228ed | 2010-03-23 21:19:54 +0100 | [diff] [blame] | 254 | printf "Release branches? [$default_suggestion] " |
Vincent Driessen | 5f860bf | 2011-02-05 08:22:38 +0100 | [diff] [blame] | 255 | if noflag defaults; then |
Joseph A. Levin | d2eccaa | 2011-02-04 21:30:15 -0600 | [diff] [blame] | 256 | read answer |
| 257 | else |
| 258 | printf "\n" |
| 259 | fi |
Vincent Driessen | 1d8bb0d | 2010-02-20 16:46:38 +0100 | [diff] [blame] | 260 | [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} |
| 261 | git config gitflow.prefix.release "$prefix" |
| 262 | fi |
| 263 | |
Vincent Driessen | f476d26 | 2010-02-20 16:23:47 +0100 | [diff] [blame] | 264 | |
| 265 | # Hotfix branches |
Vincent Driessen | 1d8bb0d | 2010-02-20 16:46:38 +0100 | [diff] [blame] | 266 | if ! git config --get gitflow.prefix.hotfix >/dev/null 2>&1 || flag force; then |
| 267 | default_suggestion=$(git config --get gitflow.prefix.hotfix || echo hotfix/) |
Vincent Driessen | f6228ed | 2010-03-23 21:19:54 +0100 | [diff] [blame] | 268 | printf "Hotfix branches? [$default_suggestion] " |
Vincent Driessen | 5f860bf | 2011-02-05 08:22:38 +0100 | [diff] [blame] | 269 | if noflag defaults; then |
Joseph A. Levin | d2eccaa | 2011-02-04 21:30:15 -0600 | [diff] [blame] | 270 | read answer |
| 271 | else |
| 272 | printf "\n" |
| 273 | fi |
Vincent Driessen | 1d8bb0d | 2010-02-20 16:46:38 +0100 | [diff] [blame] | 274 | [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} |
| 275 | git config gitflow.prefix.hotfix "$prefix" |
| 276 | fi |
| 277 | |
Vincent Driessen | f476d26 | 2010-02-20 16:23:47 +0100 | [diff] [blame] | 278 | |
| 279 | # Support branches |
Vincent Driessen | 1d8bb0d | 2010-02-20 16:46:38 +0100 | [diff] [blame] | 280 | if ! git config --get gitflow.prefix.support >/dev/null 2>&1 || flag force; then |
| 281 | default_suggestion=$(git config --get gitflow.prefix.support || echo support/) |
Vincent Driessen | f6228ed | 2010-03-23 21:19:54 +0100 | [diff] [blame] | 282 | printf "Support branches? [$default_suggestion] " |
Vincent Driessen | 5f860bf | 2011-02-05 08:22:38 +0100 | [diff] [blame] | 283 | if noflag defaults; then |
Joseph A. Levin | d2eccaa | 2011-02-04 21:30:15 -0600 | [diff] [blame] | 284 | read answer |
| 285 | else |
| 286 | printf "\n" |
| 287 | fi |
Vincent Driessen | 1d8bb0d | 2010-02-20 16:46:38 +0100 | [diff] [blame] | 288 | [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} |
| 289 | git config gitflow.prefix.support "$prefix" |
| 290 | fi |
| 291 | |
Vincent Driessen | f476d26 | 2010-02-20 16:23:47 +0100 | [diff] [blame] | 292 | |
| 293 | # Version tag prefix |
Vincent Driessen | 1d8bb0d | 2010-02-20 16:46:38 +0100 | [diff] [blame] | 294 | if ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1 || flag force; then |
| 295 | default_suggestion=$(git config --get gitflow.prefix.versiontag || echo "") |
Vincent Driessen | f6228ed | 2010-03-23 21:19:54 +0100 | [diff] [blame] | 296 | printf "Version tag prefix? [$default_suggestion] " |
Vincent Driessen | 5f860bf | 2011-02-05 08:22:38 +0100 | [diff] [blame] | 297 | if noflag defaults; then |
Joseph A. Levin | d2eccaa | 2011-02-04 21:30:15 -0600 | [diff] [blame] | 298 | read answer |
| 299 | else |
| 300 | printf "\n" |
| 301 | fi |
Vincent Driessen | 1d8bb0d | 2010-02-20 16:46:38 +0100 | [diff] [blame] | 302 | [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} |
| 303 | git config gitflow.prefix.versiontag "$prefix" |
| 304 | fi |
| 305 | |
Vincent Driessen | 6188206 | 2010-02-18 12:32:20 +0100 | [diff] [blame] | 306 | |
| 307 | # TODO: what to do with origin? |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 308 | } |
| 309 | |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 310 | cmd_help() { |
| 311 | usage |
| 312 | exit 0 |
| 313 | } |