From 83d2a072ba3d0dace29b0fcbdfdaee2353810a6f Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Tue, 20 Oct 2015 10:14:28 -0400 Subject: [PATCH 01/39] Preparation for new development cycle after release 1.9.1 --- Changes.mdown | 3 +++ git-flow-version | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Changes.mdown b/Changes.mdown index d87f1ad1..b9d91e0b 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -26,6 +26,9 @@ # Changelog +#### 1.10.0-dev.1 +* Preparation for new development cycle. + #### 1.9.1 [Peter van der Does][petervanderdoes] * Bugfix: git-flow directories are not set correctly diff --git a/git-flow-version b/git-flow-version index 95a8957f..04ec2944 100644 --- a/git-flow-version +++ b/git-flow-version @@ -35,7 +35,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -GITFLOW_VERSION=1.9.1 +GITFLOW_VERSION=1.10.0-dev.1 initialize() { # A function can not be empty. Comments count as empty. From 0c6712fa44b50ae2de94dcc20b70043af77e2baa Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Tue, 1 Dec 2015 14:03:54 -0500 Subject: [PATCH 02/39] Add screencast git flow init --- README.mdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.mdown b/README.mdown index bf8c26ce..2ff87ba7 100644 --- a/README.mdown +++ b/README.mdown @@ -114,6 +114,7 @@ those questions to accept the (sane) default suggestions. The ``-d`` flag will accept all defaults. +![Screencast git flow init](http://i.imgur.com/lFQbY5V.gif) ### Creating feature/release/hotfix/support branches From 67d87fc84d1ee032eec68c58ad1d7e2896b249cc Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Mon, 21 Mar 2016 19:07:30 -0400 Subject: [PATCH 03/39] Fix github links --- README.mdown | 8 +++----- contrib/gitflow-installer.sh | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.mdown b/README.mdown index 2ff87ba7..7cc24468 100644 --- a/README.mdown +++ b/README.mdown @@ -21,7 +21,7 @@ Or have a look at one of these screen casts: ## Installing git-flow -See the Wiki for up-to-date [Installation Instructions](https://github.com/petervanderdoes/gitflow/wiki/Installation). +See the Wiki for up-to-date [Installation Instructions](https://github.com/petervanderdoes/gitflow-avh/wiki/Installation). ## Integration with your shell @@ -37,7 +37,7 @@ for the commands not found in the original git-flow. ## FAQ -* See the [FAQ](http://github.com/petervanderdoes/gitflow/wiki/FAQ) section +* See the [FAQ](http://github.com/petervanderdoes/gitflow-avh/wiki/FAQ) section of the project Wiki. * Version Numbering Scheme. Starting with version 1.0, the project uses the following scheme: @@ -47,7 +47,7 @@ Starting with version 1.0, the project uses the following scheme: This project is under constant development. Feedback and suggestions are very welcome and I encourage you to use the [Issues -list](http://github.com/petervanderdoes/gitflow/issues) on Github to provide that +list](http://github.com/petervanderdoes/gitflow-avh/issues) on Github to provide that feedback. Feel free to fork this repository and to commit your additions. For a list of @@ -199,5 +199,3 @@ in another way, however, consider donating through PayPal: [1]: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=S85FXJ9EBHAF2&lc=US&item_name=gitflow&item_number=gitflow&no_note=0&cn=Add%20special%20instructions%20to%20the%20seller&no_shipping=1&rm=1&return=https%3a%2f%2fgithub%2ecom%2fpetervanderdoes%2fgitflow&cancel_return=https%3a%2f%2fgithub%2ecom%2fpetervanderdoes%2fgitflow¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted [2]: https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/petervanderdoes/gitflow/trend.png)](https://bitdeli.com/free "Bitdeli Badge") diff --git a/contrib/gitflow-installer.sh b/contrib/gitflow-installer.sh index 93a3b80f..e78403fc 100644 --- a/contrib/gitflow-installer.sh +++ b/contrib/gitflow-installer.sh @@ -2,10 +2,10 @@ # git-flow make-less installer for *nix systems, by Rick Osborne # Based on the git-flow core Makefile: -# http://github.com/petervanderdoes/gitflow/blob/master/Makefile +# http://github.com/petervanderdoes/gitflow-avh/blob/master/Makefile # Licensed under the same restrictions as git-flow: -# http://github.com/petervanderdoes/gitflow/blob/develop/LICENSE +# http://github.com/petervanderdoes/gitflow-avh/blob/develop/LICENSE # Updated for the fork at petervanderdoes From 07bfcc0123ac6eac81dcaaedaa1444bd9492968e Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Thu, 14 Apr 2016 11:54:25 -0400 Subject: [PATCH 04/39] Add config file --- .editorconfig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..7ce66db7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# This is the top-most .editorconfig file; do not search in parent directories. +root = true + +[*] +end_of_line = LF +insert_final_newline = true +trim_trailing_whitespace = true + +[Changes.mdown] +indent_style = space +indent_size = 2 + +[*.mdown] +trim_trailing_whitespace = false + +[{Makefile, makefile, GNUmakefile}] +indent_style = tab +indent_size = 4 From a06ee2a445c33639058b6d37a98123eb40baa411 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Thu, 14 Apr 2016 11:57:25 -0400 Subject: [PATCH 05/39] Small trivial change --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0e81a39f..3cdd9055 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # # Original Author: # 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: # From 1d73af4b14b2cee524f19a3bc50477bdd3a82119 Mon Sep 17 00:00:00 2001 From: Cararus Eugeniu Date: Wed, 13 Apr 2016 02:19:49 +0100 Subject: [PATCH 06/39] Issue #243 Add AVH meaning. Documentation never mentions what "AVH" stands for #243 --- README.mdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.mdown b/README.mdown index 7cc24468..6603d0af 100644 --- a/README.mdown +++ b/README.mdown @@ -42,6 +42,7 @@ of the project Wiki. * Version Numbering Scheme. Starting with version 1.0, the project uses the following scheme: \.\.\\ +* AVH is the acronym of "A VirtualHome" ## Please help out From a364cafe5b285e73a86b84b4890e8aad37790078 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Fri, 15 Apr 2016 11:50:41 -0400 Subject: [PATCH 07/39] Update of the contributers. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index f6bcf1ea..505a4130 100644 --- a/AUTHORS +++ b/AUTHORS @@ -31,6 +31,7 @@ Alexander Groß Alexander Norström Alexander Zeitler Brian St. Pierre +Cararus Eugeniu Chad Walker Craig Fowler Emre Berge Ergenekon From c42e32eb6cf730cc353fd5828713659e4f0a1257 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Fri, 15 Apr 2016 11:53:46 -0400 Subject: [PATCH 08/39] Update with changes. --- Changes.mdown | 5 +++-- git-flow-version | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Changes.mdown b/Changes.mdown index b9d91e0b..9c3d0be3 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -26,8 +26,9 @@ # Changelog -#### 1.10.0-dev.1 -* Preparation for new development cycle. +#### 1.10.0-dev.7 +* Update github links. +* Add explanation of AVH. #### 1.9.1 [Peter van der Does][petervanderdoes] diff --git a/git-flow-version b/git-flow-version index 04ec2944..b54ad929 100644 --- a/git-flow-version +++ b/git-flow-version @@ -35,7 +35,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -GITFLOW_VERSION=1.10.0-dev.1 +GITFLOW_VERSION=1.10.0-dev.7 initialize() { # A function can not be empty. Comments count as empty. From ee5d955380010da3427d2e7ad6aea65d51000189 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sat, 16 Apr 2016 09:26:47 -0400 Subject: [PATCH 09/39] Link to video is dead Replace the current link to a link on vimeo. --- README.mdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mdown b/README.mdown index 6603d0af..9f46fc75 100644 --- a/README.mdown +++ b/README.mdown @@ -16,7 +16,7 @@ Or have a look at one of these screen casts: * [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) +* [On the path with git-flow](https://vimeo.com/codesherpas/on-the-path-gitflow) (by Dave Bock) ## Installing git-flow From f4e9b78631706fe1f80e14933a3885884d8808c4 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sat, 16 Apr 2016 21:46:40 -0400 Subject: [PATCH 10/39] Add ability to push/notpush branches/tag involved. Sometimes it's not wanted to push a branch or tag when a release is finished. --- git-flow-release | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/git-flow-release b/git-flow-release index 47c3b138..8e5fd517 100644 --- a/git-flow-release +++ b/git-flow-release @@ -179,9 +179,13 @@ _finish_from_develop() { fi if flag push; then - git_do push "$ORIGIN" "$DEVELOP_BRANCH" || die "Could not push branch '$DEVELOP_BRANCH' to remote '$ORIGIN'." - git_do push "$ORIGIN" "$MASTER_BRANCH" || die "Could not push branch '$MASTER_BRANCH' to remote '$ORIGIN'." - if noflag notag; then + if flag pushdevelop; then + git_do push "$ORIGIN" "$DEVELOP_BRANCH" || die "Could not push branch '$DEVELOP_BRANCH' to remote '$ORIGIN'." + fi + if flag pushproduction; then + git_do push "$ORIGIN" "$MASTER_BRANCH" || die "Could not push branch '$MASTER_BRANCH' to remote '$ORIGIN'." + fi + if noflag notag && flag pushtag; then git_do push --tags "$ORIGIN" || die "Could not push tags to remote '$ORIGIN'." fi fi @@ -339,8 +343,10 @@ _finish_base() { fi if flag push; then - git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." - if noflag notag; then + if flag pushdevelop; then + git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." + fi + if noflag notag && flag pushtag; then git_do push --tags "$ORIGIN" || die "Could not push tags to remote '$ORIGIN'." fi fi @@ -592,6 +598,9 @@ u,signingkey! Use the given GPG-key for the digital signature (implies -s) m,message! Use the given tag message f,[no]messagefile= Use the contents of the given file as a tag message p,[no]push Push to origin after performing finish +[no]pushproduction Push the production branch +[no]pushdevelop Push the develop branch +[no]pushtag Push the tag k,[no]keep Keep branch after performing finish [no]keepremote Keep the remote branch [no]keeplocal Keep the local branch @@ -607,6 +616,9 @@ S,[no]squash Squash release during merge 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 'pushproduction' false "push the production branch" + DEFINE_boolean 'pushdevelop' false "push the develop branch" + DEFINE_boolean 'pushtag' false "push the tag" DEFINE_boolean 'keep' false "keep branch after performing finish" k DEFINE_boolean 'keepremote' false "keep the remote branch" DEFINE_boolean 'keeplocal' false "keep the local branch" @@ -620,6 +632,9 @@ S,[no]squash Squash release during merge gitflow_override_flag_boolean "release.finish.fetch" "fetch" gitflow_override_flag_boolean "release.finish.sign" "sign" gitflow_override_flag_boolean "release.finish.push" "push" + gitflow_override_flag_boolean "release.finish.pushproduction" "pushproduction" + gitflow_override_flag_boolean "release.finish.pushdevelop" "pushdevelop" + gitflow_override_flag_boolean "release.finish.pushtag" "pushtag" gitflow_override_flag_boolean "release.finish.keep" "keep" gitflow_override_flag_boolean "release.finish.keepremote" "keepremote" gitflow_override_flag_boolean "release.finish.keeplocal" "keeplocal" @@ -663,6 +678,17 @@ S,[no]squash Squash release during merge FLAGS_keep=$FLAGS_TRUE fi + # Pushing implies we push all. + if flag push; then + FLAGS_pushproduction=$FLAGS_TRUE + FLAGS_pushdevelop=$FLAGS_TRUE + FLAGS_pushtag=$FLAGS_TRUE + fi + # If we push either of these it means we need to do a push + if flag pushproduction || flag pushdevelop || flag pushtag; then + FLAGS_push=$FLAGS_TRUE + fi + # Sanity checks require_branch "$BRANCH" require_clean_working_tree From 07df450749572dc6d9477dfd997e6a6620005d9a Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sat, 16 Apr 2016 21:47:59 -0400 Subject: [PATCH 11/39] Update with the change made. --- Changes.mdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changes.mdown b/Changes.mdown index 9c3d0be3..ff315ca9 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -27,8 +27,10 @@ # Changelog #### 1.10.0-dev.7 +[Peter van der Does][petervanderdoes] * Update github links. * Add explanation of AVH. +* Add ability when finishing a release to push or not push the branches and/or tag involved. #### 1.9.1 [Peter van der Does][petervanderdoes] From 6e18bca786577618a64f9bd30c8ca4f705e632cb Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sat, 16 Apr 2016 21:48:20 -0400 Subject: [PATCH 12/39] Version bump 1.10.0-dev.12 --- Changes.mdown | 2 +- git-flow-version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changes.mdown b/Changes.mdown index ff315ca9..cd36dd6c 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -26,7 +26,7 @@ # Changelog -#### 1.10.0-dev.7 +#### 1.10.0-dev.12 [Peter van der Does][petervanderdoes] * Update github links. * Add explanation of AVH. diff --git a/git-flow-version b/git-flow-version index b54ad929..aacf70d3 100644 --- a/git-flow-version +++ b/git-flow-version @@ -35,7 +35,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -GITFLOW_VERSION=1.10.0-dev.7 +GITFLOW_VERSION=1.10.0-dev.12 initialize() { # A function can not be empty. Comments count as empty. From 5bcfed93679d09931c92bf635389726d1b12f94f Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sat, 16 Apr 2016 22:11:21 -0400 Subject: [PATCH 13/39] Release from a base branch gets errors on finishing. The finishing of a release branch based on a branch other than develop fails with errors. --- Changes.mdown | 1 + git-flow-release | 39 +++++++++++++-------------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/Changes.mdown b/Changes.mdown index cd36dd6c..a5e0c2a6 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -31,6 +31,7 @@ * Update github links. * Add explanation of AVH. * Add ability when finishing a release to push or not push the branches and/or tag involved. +* The finishing of a release branch based on a branch other than develop fails with errors. #### 1.9.1 [Peter van der Does][petervanderdoes] diff --git a/git-flow-release b/git-flow-release index 8e5fd517..8dd3e969 100644 --- a/git-flow-release +++ b/git-flow-release @@ -264,7 +264,19 @@ _finish_base() { run_pre_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH" - git_do checkout "$BASE_BRANCH" || die "Could not check out branch '$BASE_BRANCH'." + # Try to merge into base branch. + # 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" "$BASE_BRANCH"; then + git_do checkout "$BASE_BRANCH" || die "Could not check out branch '$BASE_BRANCH'." + 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? + flag squash_info && gitflow_create_squash_message "Merged release branch '$BRANCH'" "$BASE_BRANCH" "$BRANCH" > "$DOT_GIT_DIR/SQUASH_MSG" + git_do commit + fi + fi if noflag notag; then # Try to tag the release. @@ -287,31 +299,6 @@ _finish_base() { fi fi - merge_branch="$BRANCH" - - # 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 "$merge_branch" "$BASE_BRANCH"; then - git_do checkout "$BASE_BRANCH" || die "Could not check out branch '$BASE_BRANCH'." - - # Accounting for 'git describe', if a release is tagged - # we use the tag commit instead of the branch. - if noflag notag; then - commit="$VERSION_PREFIX$VERSION" - else - commit="$BRANCH" - fi - - if noflag squash; then - git_do merge --no-ff "$commit" || die "There were merge conflicts." # TODO: What do we do now? - else - git_do merge --squash "$commit" || die "There were merge conflicts." # TODO: What do we do now? - flag squash_info && gitflow_create_squash_message "Merged release branch '$BRANCH'" "$BASE_BRANCH" "$BRANCH" > "$DOT_GIT_DIR/SQUASH_MSG" - git_do commit - fi - fi - run_post_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH" # Delete branch From 4b1257aa6e96c482b33dd42fe7181194041b9191 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sat, 14 May 2016 20:04:21 -0400 Subject: [PATCH 14/39] Implement Fast Forward master --- git-flow-release | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/git-flow-release b/git-flow-release index 8dd3e969..2e667fbe 100644 --- a/git-flow-release +++ b/git-flow-release @@ -40,7 +40,7 @@ # Called when the base of the release is the $DEVELOP_BRANCH # _finish_from_develop() { - local opts merge_branch commit keepmsg remotebranchdeleted localbranchdeleted + local opts merge_branch commit keepmsg remotebranchdeleted localbranchdeleted compare_refs_result merge_result remotebranchdeleted=$FLAGS_FALSE localbranchdeleted=$FLAGS_FALSE @@ -56,7 +56,31 @@ _finish_from_develop() { require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH" fi if git_remote_branch_exists "$ORIGIN/$MASTER_BRANCH"; then - require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" + if flag ff-master; then + git_compare_refs "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" + compare_refs_result=$? + + if [ $compare_refs_result -gt 0 ]; then + warn "Branches '"$MASTER_BRANCH"' and '"$ORIGIN/$MASTER_BRANCH"' have diverged." + if [ $compare_refs_result -eq 1 ]; then + warn "Fast forwarding '"$MASTER_BRANCH"'." + git_do checkout "$MASTER_BRANCH" || die "Could not check out branch '$MASTER_BRANCH'." + git_do merge --ff-only "$ORIGIN/$MASTER_BRANCH" >/dev/null 2>&1 + merge_result=$? + git_do checkout "$BRANCH" + if [ $merge_result -gt 0 ]; then + die "'"$MASTER_BRANCH"' can not be fast forwarded." + fi + elif [ $compare_refs_result -eq 2 ]; then + # Warn here, since there is no harm in being ahead + warn "And local branch '$1' is ahead of '$2'." + else + die "Branches need merging first." + fi + fi + else + require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" + fi fi if git_remote_branch_exists "$ORIGIN/$DEVELOP_BRANCH"; then require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" @@ -595,6 +619,7 @@ D,[no]force_delete Force delete release branch after finish n,[no]tag Don't tag this release b,[no]nobackmerge Don't back-merge master, or tag if applicable, in develop S,[no]squash Squash release during merge +[no]ff-master Fast forward master branch if possible " # Define flags DEFINE_boolean 'fetch' false "fetch from $ORIGIN before performing finish" F @@ -614,6 +639,7 @@ S,[no]squash Squash release during merge DEFINE_boolean 'nobackmerge' false "don't back-merge $MASTER_BRANCH, or tag if applicable, in $DEVELOP_BRANCH " b DEFINE_boolean 'squash' false "squash release during merge" S DEFINE_boolean 'squash-info' false "add branch info during squash" + DEFINE_boolean 'ff-master' false "fast forward master branch if possible" # Override defaults with values from config gitflow_override_flag_boolean "release.finish.fetch" "fetch" @@ -630,6 +656,7 @@ S,[no]squash Squash release during merge gitflow_override_flag_boolean "release.finish.nobackmerge" "nobackmerge" gitflow_override_flag_boolean "release.finish.squash" "squash" gitflow_override_flag_boolean "release.finish.squash-info" "squash_info" + gitflow_override_flag_boolean "release.finish.ff-master" "ff-master" gitflow_override_flag_string "release.finish.signingkey" "signingkey" gitflow_override_flag_string "release.finish.message" "message" gitflow_override_flag_string "release.finish.messagefile" "messagefile" From 5436c06e237917dc705858dbd2073004f683315b Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sat, 14 May 2016 20:22:58 -0400 Subject: [PATCH 15/39] Version bump 1.10.0-dev.16 --- Changes.mdown | 2 +- git-flow-version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changes.mdown b/Changes.mdown index a5e0c2a6..5db00a02 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -26,7 +26,7 @@ # Changelog -#### 1.10.0-dev.12 +#### 1.10.0-dev.16 [Peter van der Does][petervanderdoes] * Update github links. * Add explanation of AVH. diff --git a/git-flow-version b/git-flow-version index aacf70d3..73874d59 100644 --- a/git-flow-version +++ b/git-flow-version @@ -35,7 +35,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -GITFLOW_VERSION=1.10.0-dev.12 +GITFLOW_VERSION=1.10.0-dev.16 initialize() { # A function can not be empty. Comments count as empty. From 8c667874723b414f157ea31abdd18bed9dbc69e0 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Thu, 19 May 2016 21:41:48 -0400 Subject: [PATCH 16/39] Finish Release: Handling Of An Empty Tag Description If tagging failed and the finish command is run again, the wrong branch receives the tag. Closes #256 --- git-flow-release | 1 + 1 file changed, 1 insertion(+) diff --git a/git-flow-release b/git-flow-release index 2e667fbe..e06f25bb 100644 --- a/git-flow-release +++ b/git-flow-release @@ -116,6 +116,7 @@ _finish_from_develop() { # In case a previous attempt to finish this release branch has failed, # but the tag was set successful, we skip it now if ! git_tag_exists "$VERSION_PREFIX$VERSION"; then + git_do checkout "$MASTER_BRANCH" || die "Could not check out branch '$MASTER_BRANCH'." if [ "$FLAGS_message" != "" ] && [ "$FLAGS_messagefile" != "" ]; then die "Use either -m,--message or -f,--messagefile. Can not use both options at the same time" fi From 2200745b55162953bcce4b8567376dc775fadb5c Mon Sep 17 00:00:00 2001 From: Kridsada Thanabulpong Date: Mon, 30 May 2016 16:13:12 +0700 Subject: [PATCH 17/39] Fix infinite loop during Darwin link resolving. --- git-flow | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-flow b/git-flow index 4118e99a..1693147e 100755 --- a/git-flow +++ b/git-flow @@ -55,7 +55,7 @@ FreeBSD|OpenBSD|NetBSD) Darwin) PRG="$0" while [ -h "$PRG" ]; do - link=$(readlink "$0") + link=$(readlink "$PRG") if expr "$link" : '/.*' > /dev/null; then PRG="$link" else From 76f010072b1371576acdcc49c90156a2f7d53e63 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sun, 5 Jun 2016 12:19:32 -0400 Subject: [PATCH 18/39] Update with fix --- Changes.mdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Changes.mdown b/Changes.mdown index 5db00a02..cc027012 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -23,6 +23,7 @@ [algernon]: https://github.com/algernon [jebmeier]: https://github.com/jebmeier [aleno]: https://github.com/aleno +[sirn]: https://github.com/sirn # Changelog @@ -33,6 +34,9 @@ * Add ability when finishing a release to push or not push the branches and/or tag involved. * The finishing of a release branch based on a branch other than develop fails with errors. +[Kridsada Thanabulpong][sirn] +* Fix infinite loop during Darwin link resolving. + #### 1.9.1 [Peter van der Does][petervanderdoes] * Bugfix: git-flow directories are not set correctly From 36f809dcf2be78d1bc8d44aa40b82d33ca66372a Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sun, 5 Jun 2016 12:21:44 -0400 Subject: [PATCH 19/39] Update of the contributers. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 505a4130..7013e169 100644 --- a/AUTHORS +++ b/AUTHORS @@ -48,6 +48,7 @@ Jon Bernard Joseph A. Levin Joshua P. Tilles Konstantin Tjuterev +Kridsada Thanabulpong Leonardo Giordani Mark Borcherding Mark Derricutt From 089e49055090159fcdc2cc53a6bcdd72eaa4e4aa Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sun, 5 Jun 2016 12:21:44 -0400 Subject: [PATCH 20/39] Version bump 1.10.0-dev.22 --- Changes.mdown | 2 +- git-flow-version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changes.mdown b/Changes.mdown index cc027012..28e075ae 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -27,7 +27,7 @@ # Changelog -#### 1.10.0-dev.16 +#### 1.10.0-dev.22 [Peter van der Does][petervanderdoes] * Update github links. * Add explanation of AVH. diff --git a/git-flow-version b/git-flow-version index 73874d59..f065cb6b 100644 --- a/git-flow-version +++ b/git-flow-version @@ -35,7 +35,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -GITFLOW_VERSION=1.10.0-dev.16 +GITFLOW_VERSION=1.10.0-dev.22 initialize() { # A function can not be empty. Comments count as empty. From ab5dc10d25c54b6c9953356bd9441aada2151726 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sat, 23 Jul 2016 19:52:37 -0400 Subject: [PATCH 21/39] Use of release config instead of hotfix --- git-flow-hotfix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-flow-hotfix b/git-flow-hotfix index fa3ab30b..35f675ad 100644 --- a/git-flow-hotfix +++ b/git-flow-hotfix @@ -404,8 +404,8 @@ S,[no]squash Squash hotfix during merge gitflow_override_flag_boolean "hotfix.finish.force-delete" "force_delete" gitflow_override_flag_boolean "hotfix.finish.notag" "notag" gitflow_override_flag_boolean "hotfix.finish.nobackmerge" "nobackmerge" - gitflow_override_flag_boolean "release.finish.squash" "squash" - gitflow_override_flag_boolean "release.finish.squash-info" "squash_info" + gitflow_override_flag_boolean "hotfix.finish.squash" "squash" + gitflow_override_flag_boolean "hotfix.finish.squash-info" "squash_info" gitflow_override_flag_string "hotfix.finish.signingkey" "signingkey" gitflow_override_flag_string "hotfix.finish.message" "message" gitflow_override_flag_string "hotfix.finish.messagefile" "messagefile" From 14917267e829699dc5c6aae5391c3842b1125368 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sat, 23 Jul 2016 19:58:11 -0400 Subject: [PATCH 22/39] Update copyright year --- Makefile | 2 +- git-flow | 2 +- git-flow-bugfix | 2 +- git-flow-config | 2 +- git-flow-feature | 2 +- git-flow-hotfix | 2 +- git-flow-init | 2 +- git-flow-log | 2 +- git-flow-release | 2 +- git-flow-support | 4 ++-- git-flow-version | 2 +- gitflow-common | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 3cdd9055..3f3ba295 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. diff --git a/git-flow b/git-flow index 1693147e..9ee6746a 100755 --- a/git-flow +++ b/git-flow @@ -10,7 +10,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. diff --git a/git-flow-bugfix b/git-flow-bugfix index 61e90a13..c124ed24 100644 --- a/git-flow-bugfix +++ b/git-flow-bugfix @@ -9,7 +9,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. diff --git a/git-flow-config b/git-flow-config index 595e1459..9850ebd2 100644 --- a/git-flow-config +++ b/git-flow-config @@ -9,7 +9,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # # Redistribution and use in source and binary forms, with or without diff --git a/git-flow-feature b/git-flow-feature index 4d33d313..3e57c673 100644 --- a/git-flow-feature +++ b/git-flow-feature @@ -9,7 +9,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. diff --git a/git-flow-hotfix b/git-flow-hotfix index 35f675ad..8290f188 100644 --- a/git-flow-hotfix +++ b/git-flow-hotfix @@ -9,7 +9,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. diff --git a/git-flow-init b/git-flow-init index f577ab08..39bbbc36 100644 --- a/git-flow-init +++ b/git-flow-init @@ -9,7 +9,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. diff --git a/git-flow-log b/git-flow-log index 43056126..ea83ffb3 100644 --- a/git-flow-log +++ b/git-flow-log @@ -9,7 +9,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. diff --git a/git-flow-release b/git-flow-release index e06f25bb..ba83e656 100644 --- a/git-flow-release +++ b/git-flow-release @@ -9,7 +9,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. diff --git a/git-flow-support b/git-flow-support index d49c0d4b..9f676fb6 100644 --- a/git-flow-support +++ b/git-flow-support @@ -9,7 +9,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. @@ -244,4 +244,4 @@ p,[no]preserve-merges Preserve merges opts="$opts -p" fi git_do rebase $opts "$BASE_BRANCH" -} \ No newline at end of file +} diff --git a/git-flow-version b/git-flow-version index f065cb6b..df208ba1 100644 --- a/git-flow-version +++ b/git-flow-version @@ -9,7 +9,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. diff --git a/gitflow-common b/gitflow-common index 24166644..0f0669a8 100644 --- a/gitflow-common +++ b/gitflow-common @@ -9,7 +9,7 @@ # http://github.com/petervanderdoes/gitflow # # Authors: -# Copyright 2012-2015 Peter van der Does. All rights reserved. +# Copyright 2012-2016 Peter van der Does. All rights reserved. # # Original Author: # Copyright 2010 Vincent Driessen. All rights reserved. From 16092994ecc3e1c9ae4a02bef9628c003c36e961 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Sat, 23 Jul 2016 20:22:02 -0400 Subject: [PATCH 23/39] On finish a release squash not always needed. When a release is finished and the release is squashed and is back merged from the master to develop there is no need to squash the commit again. --- git-flow-release | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/git-flow-release b/git-flow-release index ba83e656..2349ba4d 100644 --- a/git-flow-release +++ b/git-flow-release @@ -155,16 +155,16 @@ _finish_from_develop() { else commit="$MASTER_BRANCH" fi - else - commit="$BRANCH" - fi - - if noflag squash; then git_do merge --no-ff "$commit" || die "There were merge conflicts." # TODO: What do we do now? else - git_do merge --squash "$commit" || die "There were merge conflicts." # TODO: What do we do now? - flag squash_info && gitflow_create_squash_message "Merged release branch '$BRANCH'" "$DEVELOP_BRANCH" "$BRANCH" > "$DOT_GIT_DIR/SQUASH_MSG" - git_do commit + commit="$BRANCH" + if noflag squash; then + git_do merge --no-ff "$commit" || die "There were merge conflicts." # TODO: What do we do now? + else + git_do merge --squash "$commit" || die "There were merge conflicts." # TODO: What do we do now? + flag squash_info && gitflow_create_squash_message "Merged release branch '$BRANCH'" "$DEVELOP_BRANCH" "$BRANCH" > "$DOT_GIT_DIR/SQUASH_MSG" + git_do commit + fi fi fi From fa07ad4a8f2cbc0d9a47ccdddc2a9a741b9604ed Mon Sep 17 00:00:00 2001 From: Juan Rial Date: Thu, 23 Jun 2016 16:42:36 +0200 Subject: [PATCH 24/39] Allow specifying the tag on hotfix/release finish This commit adds an extra flag -T (--tagname) to the hotfix and release subcommands, allowing the user to specify a tag name different from the branch name. This permits usage of descriptive hotfix and release branch names. --- git-flow-hotfix | 29 +++++++++++++++++++---------- git-flow-release | 48 +++++++++++++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 29 deletions(-) diff --git a/git-flow-hotfix b/git-flow-hotfix index 8290f188..4df4e167 100644 --- a/git-flow-hotfix +++ b/git-flow-hotfix @@ -375,6 +375,7 @@ D,[no]force_delete Force delete hotfix branch after finish n,[no]notag Don't tag this hotfix b,[no]nobackmerge Don't back-merge master, or tag if applicable, in develop S,[no]squash Squash hotfix during merge +T,tagname Use given tag name " local opts commit keepmsg remotebranchdeleted localbranchdeleted @@ -393,6 +394,7 @@ S,[no]squash Squash hotfix during merge DEFINE_boolean 'nobackmerge' false "don't back-merge $MASTER_BRANCH, or tag if applicable, in $DEVELOP_BRANCH " b DEFINE_boolean 'squash' false "squash release during merge" S DEFINE_boolean 'squash-info' false "add branch info during squash" + DEFINE_string 'tagname' "" "use the given tag name" T # Override defaults with values from config gitflow_override_flag_boolean "hotfix.finish.fetch" "fetch" @@ -418,6 +420,13 @@ S,[no]squash Squash hotfix during merge gitflow_use_current_branch_version fi + # Use branch name if no tag name is given + if [ "$FLAGS_tagname" != "" ]; then + TAGNAME=$FLAGS_tagname + else + TAGNAME=$VERSION + fi + remotebranchdeleted=$FLAGS_FALSE localbranchdeleted=$FLAGS_FALSE @@ -491,13 +500,13 @@ S,[no]squash Squash hotfix during merge if noflag notag; then # We ask for a tag, be sure it does not exists or # points to the latest hotfix commit - if git_tag_exists "$VERSION_PREFIX$VERSION"; then - git_compare_refs "$BRANCH" "$VERSION_PREFIX$VERSION"^2 2>/dev/null + if git_tag_exists "$VERSION_PREFIX$TAGNAME"; then + git_compare_refs "$BRANCH" "$VERSION_PREFIX$TAGNAME"^2 2>/dev/null [ $? -eq 0 ] || die "Tag already exists and does not point to hotfix branch '$BRANCH'" fi fi - run_pre_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH" + run_pre_hook "$VERSION_PREFIX$TAGNAME" "$ORIGIN" "$BRANCH" # Try to merge into BASE. # In case a previous attempt to finish this release branch has failed, @@ -517,7 +526,7 @@ S,[no]squash Squash hotfix during merge # 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 - if ! git_tag_exists "$VERSION_PREFIX$VERSION"; then + if ! git_tag_exists "$VERSION_PREFIX$TAGNAME"; then if [ "$FLAGS_message" != "" ] && [ "$FLAGS_messagefile" != "" ]; then die "Use either -m,--message or -f,--messagefile. Can not use both options at the same time" fi @@ -526,11 +535,11 @@ S,[no]squash Squash hotfix during merge [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'" if [ "$FLAGS_message" != "" ]; then # Run filter on the tag message - FLAGS_message=$(run_filter_hook hotfix-finish-tag-message "${FLAGS_message}" "$VERSION_PREFIX$VERSION") + FLAGS_message=$(run_filter_hook hotfix-finish-tag-message "${FLAGS_message}" "$VERSION_PREFIX$TAGNAME") opts="$opts -m '$FLAGS_message'" fi [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'" - eval git_do tag $opts "$VERSION_PREFIX$VERSION" || die "Tagging failed. Please run finish again to retry." + eval git_do tag $opts "$VERSION_PREFIX$TAGNAME" || die "Tagging failed. Please run finish again to retry." fi fi @@ -553,7 +562,7 @@ S,[no]squash Squash hotfix during merge # Accounting for 'git describe', if a release is tagged # we use the tag commit instead of the branch. if noflag notag; then - commit="$VERSION_PREFIX$VERSION" + commit="$VERSION_PREFIX$TAGNAME" else commit="$BASE_BRANCH" fi @@ -566,7 +575,7 @@ S,[no]squash Squash hotfix during merge fi fi - run_post_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH" + run_post_hook "$VERSION_PREFIX$TAGNAME" "$ORIGIN" "$BRANCH" # Delete branch if noflag keep; then @@ -614,11 +623,11 @@ S,[no]squash Squash hotfix during merge fi echo "- Hotfix branch '$BRANCH' has been merged into '$BASE_BRANCH'" if noflag notag; then - echo "- The hotfix was tagged '$VERSION_PREFIX$VERSION'" + echo "- The hotfix was tagged '$VERSION_PREFIX$TAGNAME'" fi if [ "$BASE_BRANCH" = "$MASTER_BRANCH" ]; then [ "$commit" = "$BASE_BRANCH" ] && echo "- Master branch '$BASE_BRANCH' has been back-merged into '$DEVELOP_BRANCH'" - [ "$commit" = "$VERSION_PREFIX$VERSION" ] && echo "- Hotfix tag '$VERSION_PREFIX$VERSION' has been back-merged into '$DEVELOP_BRANCH'" + [ "$commit" = "$VERSION_PREFIX$TAGNAME" ] && echo "- Hotfix tag '$VERSION_PREFIX$TAGNAME' has been back-merged into '$DEVELOP_BRANCH'" [ "$commit" = "$BRANCH" ] && echo "- Hotfix branch '$BRANCH' has been merged into '$DEVELOP_BRANCH'" fi if noflag keep; then diff --git a/git-flow-release b/git-flow-release index 2349ba4d..e6b43a3a 100644 --- a/git-flow-release +++ b/git-flow-release @@ -89,13 +89,13 @@ _finish_from_develop() { if noflag notag; then # We ask for a tag, be sure it does not exists or # points to the latest hotfix commit - if git_tag_exists "$VERSION_PREFIX$VERSION"; then - git_compare_refs "$BRANCH" "$VERSION_PREFIX$VERSION"^2 2>/dev/null + if git_tag_exists "$VERSION_PREFIX$TAGNAME"; then + git_compare_refs "$BRANCH" "$VERSION_PREFIX$TAGNAME"^2 2>/dev/null [ $? -eq 0 ] || die "Tag already exists and does not point to release branch '$BRANCH'" fi fi - run_pre_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH" + run_pre_hook "$VERSION_PREFIX$TAGNAME" "$ORIGIN" "$BRANCH" # Try to merge into master. # In case a previous attempt to finish this release branch has failed, @@ -115,7 +115,7 @@ _finish_from_develop() { # 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 - if ! git_tag_exists "$VERSION_PREFIX$VERSION"; then + if ! git_tag_exists "$VERSION_PREFIX$TAGNAME"; then git_do checkout "$MASTER_BRANCH" || die "Could not check out branch '$MASTER_BRANCH'." if [ "$FLAGS_message" != "" ] && [ "$FLAGS_messagefile" != "" ]; then die "Use either -m,--message or -f,--messagefile. Can not use both options at the same time" @@ -125,11 +125,11 @@ _finish_from_develop() { [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'" if [ "$FLAGS_message" != "" ]; then # Run filter on the tag message - FLAGS_message=$(run_filter_hook release-finish-tag-message "${FLAGS_message}" "$VERSION_PREFIX$VERSION") + FLAGS_message=$(run_filter_hook release-finish-tag-message "${FLAGS_message}" "$VERSION_PREFIX$TAGNAME") opts="$opts -m '$FLAGS_message'" fi [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'" - eval git_do tag $opts "$VERSION_PREFIX$VERSION" || die "Tagging failed. Please run finish again to retry." + eval git_do tag $opts "$VERSION_PREFIX$TAGNAME" || die "Tagging failed. Please run finish again to retry." fi fi @@ -151,7 +151,7 @@ _finish_from_develop() { # Accounting for 'git describe', if a release is tagged # we use the tag commit instead of the branch. if noflag notag; then - commit="$VERSION_PREFIX$VERSION" + commit="$VERSION_PREFIX$TAGNAME" else commit="$MASTER_BRANCH" fi @@ -168,7 +168,7 @@ _finish_from_develop() { fi fi - run_post_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH" + run_post_hook "$VERSION_PREFIX$TAGNAME" "$ORIGIN" "$BRANCH" # Delete branch if noflag keep; then @@ -222,10 +222,10 @@ _finish_from_develop() { fi echo "- Release branch '$BRANCH' has been merged into '$MASTER_BRANCH'" if noflag notag; then - echo "- The release was tagged '$VERSION_PREFIX$VERSION'" + echo "- The release was tagged '$VERSION_PREFIX$TAGNAME'" fi [ "$commit" = "$MASTER_BRANCH" ] && echo "- Master branch '$MASTER_BRANCH' has been back-merged into '$DEVELOP_BRANCH'" - [ "$commit" = "$VERSION_PREFIX$VERSION" ] && echo "- Release tag '$VERSION_PREFIX$VERSION' has been back-merged into '$DEVELOP_BRANCH'" + [ "$commit" = "$VERSION_PREFIX$TAGNAME" ] && echo "- Release tag '$VERSION_PREFIX$TAGNAME' has been back-merged into '$DEVELOP_BRANCH'" [ "$commit" = "$BRANCH" ] && echo "- Release branch '$BRANCH' has been merged into '$DEVELOP_BRANCH'" if noflag keep; then @@ -281,13 +281,13 @@ _finish_base() { if noflag notag; then # We ask for a tag, be sure it does not exists or # points to the latest hotfix commit - if git_tag_exists "$VERSION_PREFIX$VERSION"; then - git_compare_refs "$BRANCH" "$VERSION_PREFIX$VERSION"^2 2>/dev/null + if git_tag_exists "$VERSION_PREFIX$TAGNAME"; then + git_compare_refs "$BRANCH" "$VERSION_PREFIX$TAGNAME"^2 2>/dev/null [ $? -eq 0 ] || die "Tag already exists and does not point to release branch '$BRANCH'" fi fi - run_pre_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH" + run_pre_hook "$VERSION_PREFIX$TAGNAME" "$ORIGIN" "$BRANCH" # Try to merge into base branch. # In case a previous attempt to finish this release branch has failed, @@ -307,7 +307,7 @@ _finish_base() { # 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 - if ! git_tag_exists "$VERSION_PREFIX$VERSION"; then + if ! git_tag_exists "$VERSION_PREFIX$TAGNAME"; then if [ "$FLAGS_message" != "" ] && [ "$FLAGS_messagefile" != "" ]; then die "Use either -m,--message or -f,--messagefile. Can not use both options at the same time" fi @@ -316,15 +316,15 @@ _finish_base() { [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'" if [ "$FLAGS_message" != "" ]; then # Run filter on the tag message - FLAGS_message=$(run_filter_hook release-finish-tag-message "${FLAGS_message}" "$VERSION_PREFIX$VERSION") + FLAGS_message=$(run_filter_hook release-finish-tag-message "${FLAGS_message}" "$VERSION_PREFIX$TAGNAME") opts="$opts -m '$FLAGS_message'" fi [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'" - eval git_do tag $opts "$VERSION_PREFIX$VERSION" || die "Tagging failed. Please run finish again to retry." + eval git_do tag $opts "$VERSION_PREFIX$TAGNAME" || die "Tagging failed. Please run finish again to retry." fi fi - run_post_hook "$VERSION_PREFIX$VERSION" "$ORIGIN" "$BRANCH" + run_post_hook "$VERSION_PREFIX$TAGNAME" "$ORIGIN" "$BRANCH" # Delete branch if noflag keep; then @@ -369,9 +369,9 @@ _finish_base() { echo "- Latest objects have been fetched from '$ORIGIN'" fi if noflag notag; then - echo "- The release was tagged '$VERSION_PREFIX$VERSION'" + echo "- The release was tagged '$VERSION_PREFIX$TAGNAME'" fi - [ "$commit" = "$VERSION_PREFIX$VERSION" ] && echo "- Release tag '$VERSION_PREFIX$VERSION' has been merged into '$BASE_BRANCH'" + [ "$commit" = "$VERSION_PREFIX$TAGNAME" ] && echo "- Release tag '$VERSION_PREFIX$TAGNAME' has been merged into '$BASE_BRANCH'" [ "$commit" = "$BRANCH" ] && echo "- Release branch '$BRANCH' has been merged into '$BASE_BRANCH'" if noflag keep; then if [ $localbranchdeleted -eq $FLAGS_TRUE ]; then @@ -621,6 +621,7 @@ n,[no]tag Don't tag this release b,[no]nobackmerge Don't back-merge master, or tag if applicable, in develop S,[no]squash Squash release during merge [no]ff-master Fast forward master branch if possible +T,tagname Use given tag name " # Define flags DEFINE_boolean 'fetch' false "fetch from $ORIGIN before performing finish" F @@ -641,6 +642,7 @@ S,[no]squash Squash release during merge DEFINE_boolean 'squash' false "squash release during merge" S DEFINE_boolean 'squash-info' false "add branch info during squash" DEFINE_boolean 'ff-master' false "fast forward master branch if possible" + DEFINE_string 'tagname' "" "use the given tag name" T # Override defaults with values from config gitflow_override_flag_boolean "release.finish.fetch" "fetch" @@ -670,12 +672,20 @@ S,[no]squash Squash release during merge gitflow_use_current_branch_version fi + # Run filter on the version VERSION=$(run_filter_hook release-finish-version $VERSION) if [ $? -eq 127 ]; then die $VERSION fi + # Use branch name if no tag name is given + if [ "$FLAGS_tagname" != "" ]; then + TAGNAME=$FLAGS_tagname + else + TAGNAME=$VERSION + fi + # As VERSION might have changed reset BRANCH with new VERSION BRANCH=$PREFIX$VERSION From 5a644cf00e812421d48f63979423e3f2e78b2e31 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Mon, 25 Jul 2016 08:18:20 -0400 Subject: [PATCH 25/39] No negate option for tagname --- git-flow-hotfix | 2 +- git-flow-release | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/git-flow-hotfix b/git-flow-hotfix index 4df4e167..df30fd9b 100644 --- a/git-flow-hotfix +++ b/git-flow-hotfix @@ -375,7 +375,7 @@ D,[no]force_delete Force delete hotfix branch after finish n,[no]notag Don't tag this hotfix b,[no]nobackmerge Don't back-merge master, or tag if applicable, in develop S,[no]squash Squash hotfix during merge -T,tagname Use given tag name +T,tagname! Use given tag name " local opts commit keepmsg remotebranchdeleted localbranchdeleted diff --git a/git-flow-release b/git-flow-release index e6b43a3a..40328aa0 100644 --- a/git-flow-release +++ b/git-flow-release @@ -621,7 +621,7 @@ n,[no]tag Don't tag this release b,[no]nobackmerge Don't back-merge master, or tag if applicable, in develop S,[no]squash Squash release during merge [no]ff-master Fast forward master branch if possible -T,tagname Use given tag name +T,tagname! Use given tag name " # Define flags DEFINE_boolean 'fetch' false "fetch from $ORIGIN before performing finish" F From 8cf08e70060b1e53fab81f3ea5a0ea530075559d Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Mon, 25 Jul 2016 08:18:28 -0400 Subject: [PATCH 26/39] Update of the contributers. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 7013e169..2a435717 100644 --- a/AUTHORS +++ b/AUTHORS @@ -47,6 +47,7 @@ John Sivak Jon Bernard Joseph A. Levin Joshua P. Tilles +Juan Rial Konstantin Tjuterev Kridsada Thanabulpong Leonardo Giordani From a8fbf2983b80695bcc8a31214338adf27d47ac72 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Mon, 25 Jul 2016 08:18:29 -0400 Subject: [PATCH 27/39] Version bump 1.10.0-dev.30 Closes #262 --- Changes.mdown | 2 +- git-flow-version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changes.mdown b/Changes.mdown index 28e075ae..6a973c3a 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -27,7 +27,7 @@ # Changelog -#### 1.10.0-dev.22 +#### 1.10.0-dev.30 [Peter van der Does][petervanderdoes] * Update github links. * Add explanation of AVH. diff --git a/git-flow-version b/git-flow-version index df208ba1..910f939f 100644 --- a/git-flow-version +++ b/git-flow-version @@ -35,7 +35,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -GITFLOW_VERSION=1.10.0-dev.22 +GITFLOW_VERSION=1.10.0-dev.30 initialize() { # A function can not be empty. Comments count as empty. From ecce3a07bf087c80d899b2e09526c50ae07b05e2 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Mon, 25 Jul 2016 16:49:25 -0400 Subject: [PATCH 28/39] Add new flag --- git-flow-feature | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/git-flow-feature b/git-flow-feature index 3e57c673..a53d482b 100644 --- a/git-flow-feature +++ b/git-flow-feature @@ -1,3 +1,4 @@ +#@IgnoreInspection BashAddShebang # # git-flow -- A collection of Git extensions to provide high-level # repository operations for Vincent Driessen's branching model. @@ -243,6 +244,7 @@ showcommands! Show git commands while executing them F,[no]fetch Fetch from origin before performing finish r,[no]rebase Rebase before merging p,[no]preserve-merges Preserve merges while rebasing +[no]push Push to origin after performing finish k,[no]keep Keep branch after performing finish keepremote! Keep the remote branch keeplocal! Keep the local branch @@ -256,6 +258,7 @@ no-ff! Never fast-forward during the merge DEFINE_boolean 'fetch' false "fetch from $ORIGIN before performing finish" F DEFINE_boolean 'rebase' false "rebase before merging" r DEFINE_boolean 'preserve-merges' false 'try to recreate merges while rebasing' p + DEFINE_boolean 'push' false "push to $ORIGIN after performing finish" p DEFINE_boolean 'keep' false "keep branch after performing finish" k DEFINE_boolean 'keepremote' false "keep the remote branch" DEFINE_boolean 'keeplocal' false "keep the local branch" @@ -268,6 +271,7 @@ no-ff! Never fast-forward during the merge gitflow_override_flag_boolean "feature.finish.fetch" "fetch" gitflow_override_flag_boolean "feature.finish.rebase" "rebase" gitflow_override_flag_boolean "feature.finish.preserve-merges" "preserve_merges" + gitflow_override_flag_boolean "feature.finish.push" "push" gitflow_override_flag_boolean "feature.finish.keep" "keep" gitflow_override_flag_boolean "feature.finish.keepremote" "keepremote" gitflow_override_flag_boolean "feature.finish.keeplocal" "keeplocal" @@ -464,6 +468,10 @@ helper_finish_cleanup() { fi fi + if flag push; then + git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." + fi + echo echo "Summary of actions:" echo "- The feature branch '$BRANCH' was merged into '$BASE_BRANCH'" From f9c363dccb4fafd5da32feda193e0aaf1e442b89 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Mon, 25 Jul 2016 16:50:28 -0400 Subject: [PATCH 29/39] Update with change --- Changes.mdown | 1 + 1 file changed, 1 insertion(+) diff --git a/Changes.mdown b/Changes.mdown index 6a973c3a..3b0b6ee9 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -33,6 +33,7 @@ * Add explanation of AVH. * Add ability when finishing a release to push or not push the branches and/or tag involved. * The finishing of a release branch based on a branch other than develop fails with errors. +* Add --push flag for feature finish. This gives the ability to push the bas branch after the finish. [Kridsada Thanabulpong][sirn] * Fix infinite loop during Darwin link resolving. From 7f66e7dfd2eac71557daf6e6402b2b91b2b4b3e7 Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Mon, 25 Jul 2016 16:50:50 -0400 Subject: [PATCH 30/39] Version bump 1.10.0-dev.34 --- Changes.mdown | 2 +- git-flow-version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Changes.mdown b/Changes.mdown index 3b0b6ee9..c0cbf20f 100644 --- a/Changes.mdown +++ b/Changes.mdown @@ -27,7 +27,7 @@ # Changelog -#### 1.10.0-dev.30 +#### 1.10.0-dev.34 [Peter van der Does][petervanderdoes] * Update github links. * Add explanation of AVH. diff --git a/git-flow-version b/git-flow-version index 910f939f..4dfb4a11 100644 --- a/git-flow-version +++ b/git-flow-version @@ -35,7 +35,7 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -GITFLOW_VERSION=1.10.0-dev.30 +GITFLOW_VERSION=1.10.0-dev.34 initialize() { # A function can not be empty. Comments count as empty. From 24708e682477622206dd1108b03ef5b7b32d964e Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Mon, 25 Jul 2016 16:53:36 -0400 Subject: [PATCH 31/39] Stage indentation to tabs --- git-flow-release | 86 ++--- gitflow-shFlags | 950 +++++++++++++++++++++++------------------------ 2 files changed, 518 insertions(+), 518 deletions(-) diff --git a/git-flow-release b/git-flow-release index 40328aa0..0db2c70e 100644 --- a/git-flow-release +++ b/git-flow-release @@ -56,30 +56,30 @@ _finish_from_develop() { require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH" fi if git_remote_branch_exists "$ORIGIN/$MASTER_BRANCH"; then - if flag ff-master; then - git_compare_refs "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" - compare_refs_result=$? - - if [ $compare_refs_result -gt 0 ]; then - warn "Branches '"$MASTER_BRANCH"' and '"$ORIGIN/$MASTER_BRANCH"' have diverged." - if [ $compare_refs_result -eq 1 ]; then - warn "Fast forwarding '"$MASTER_BRANCH"'." - git_do checkout "$MASTER_BRANCH" || die "Could not check out branch '$MASTER_BRANCH'." - git_do merge --ff-only "$ORIGIN/$MASTER_BRANCH" >/dev/null 2>&1 - merge_result=$? - git_do checkout "$BRANCH" - if [ $merge_result -gt 0 ]; then - die "'"$MASTER_BRANCH"' can not be fast forwarded." - fi - elif [ $compare_refs_result -eq 2 ]; then - # Warn here, since there is no harm in being ahead - warn "And local branch '$1' is ahead of '$2'." - else - die "Branches need merging first." - fi - fi + if flag ff-master; then + git_compare_refs "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" + compare_refs_result=$? + + if [ $compare_refs_result -gt 0 ]; then + warn "Branches '"$MASTER_BRANCH"' and '"$ORIGIN/$MASTER_BRANCH"' have diverged." + if [ $compare_refs_result -eq 1 ]; then + warn "Fast forwarding '"$MASTER_BRANCH"'." + git_do checkout "$MASTER_BRANCH" || die "Could not check out branch '$MASTER_BRANCH'." + git_do merge --ff-only "$ORIGIN/$MASTER_BRANCH" >/dev/null 2>&1 + merge_result=$? + git_do checkout "$BRANCH" + if [ $merge_result -gt 0 ]; then + die "'"$MASTER_BRANCH"' can not be fast forwarded." + fi + elif [ $compare_refs_result -eq 2 ]; then + # Warn here, since there is no harm in being ahead + warn "And local branch '$1' is ahead of '$2'." + else + die "Branches need merging first." + fi + fi else - require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" + require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" fi fi if git_remote_branch_exists "$ORIGIN/$DEVELOP_BRANCH"; then @@ -116,7 +116,7 @@ _finish_from_develop() { # In case a previous attempt to finish this release branch has failed, # but the tag was set successful, we skip it now if ! git_tag_exists "$VERSION_PREFIX$TAGNAME"; then - git_do checkout "$MASTER_BRANCH" || die "Could not check out branch '$MASTER_BRANCH'." + git_do checkout "$MASTER_BRANCH" || die "Could not check out branch '$MASTER_BRANCH'." if [ "$FLAGS_message" != "" ] && [ "$FLAGS_messagefile" != "" ]; then die "Use either -m,--message or -f,--messagefile. Can not use both options at the same time" fi @@ -159,12 +159,12 @@ _finish_from_develop() { else commit="$BRANCH" if noflag squash; then - git_do merge --no-ff "$commit" || die "There were merge conflicts." # TODO: What do we do now? - else - git_do merge --squash "$commit" || die "There were merge conflicts." # TODO: What do we do now? - flag squash_info && gitflow_create_squash_message "Merged release branch '$BRANCH'" "$DEVELOP_BRANCH" "$BRANCH" > "$DOT_GIT_DIR/SQUASH_MSG" - git_do commit - fi + git_do merge --no-ff "$commit" || die "There were merge conflicts." # TODO: What do we do now? + else + git_do merge --squash "$commit" || die "There were merge conflicts." # TODO: What do we do now? + flag squash_info && gitflow_create_squash_message "Merged release branch '$BRANCH'" "$DEVELOP_BRANCH" "$BRANCH" > "$DOT_GIT_DIR/SQUASH_MSG" + git_do commit + fi fi fi @@ -204,11 +204,11 @@ _finish_from_develop() { fi if flag push; then - if flag pushdevelop; then - git_do push "$ORIGIN" "$DEVELOP_BRANCH" || die "Could not push branch '$DEVELOP_BRANCH' to remote '$ORIGIN'." + if flag pushdevelop; then + git_do push "$ORIGIN" "$DEVELOP_BRANCH" || die "Could not push branch '$DEVELOP_BRANCH' to remote '$ORIGIN'." fi if flag pushproduction; then - git_do push "$ORIGIN" "$MASTER_BRANCH" || die "Could not push branch '$MASTER_BRANCH' to remote '$ORIGIN'." + git_do push "$ORIGIN" "$MASTER_BRANCH" || die "Could not push branch '$MASTER_BRANCH' to remote '$ORIGIN'." fi if noflag notag && flag pushtag; then git_do push --tags "$ORIGIN" || die "Could not push tags to remote '$ORIGIN'." @@ -355,8 +355,8 @@ _finish_base() { fi if flag push; then - if flag pushdevelop; then - git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." + if flag pushdevelop; then + git_do push "$ORIGIN" "$BASE_BRANCH" || die "Could not push branch '$BASE_BRANCH' to remote '$ORIGIN'." fi if noflag notag && flag pushtag; then git_do push --tags "$ORIGIN" || die "Could not push tags to remote '$ORIGIN'." @@ -630,9 +630,9 @@ T,tagname! Use given tag name 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 'pushproduction' false "push the production branch" - DEFINE_boolean 'pushdevelop' false "push the develop branch" - DEFINE_boolean 'pushtag' false "push the tag" + DEFINE_boolean 'pushproduction' false "push the production branch" + DEFINE_boolean 'pushdevelop' false "push the develop branch" + DEFINE_boolean 'pushtag' false "push the tag" DEFINE_boolean 'keep' false "keep branch after performing finish" k DEFINE_boolean 'keepremote' false "keep the remote branch" DEFINE_boolean 'keeplocal' false "keep the local branch" @@ -705,13 +705,13 @@ T,tagname! Use given tag name # Pushing implies we push all. if flag push; then - FLAGS_pushproduction=$FLAGS_TRUE - FLAGS_pushdevelop=$FLAGS_TRUE - FLAGS_pushtag=$FLAGS_TRUE + FLAGS_pushproduction=$FLAGS_TRUE + FLAGS_pushdevelop=$FLAGS_TRUE + FLAGS_pushtag=$FLAGS_TRUE fi # If we push either of these it means we need to do a push - if flag pushproduction || flag pushdevelop || flag pushtag; then - FLAGS_push=$FLAGS_TRUE + if flag pushproduction || flag pushdevelop || flag pushtag; then + FLAGS_push=$FLAGS_TRUE fi # Sanity checks diff --git a/gitflow-shFlags b/gitflow-shFlags index d3bbc5c4..51ba761b 100644 --- a/gitflow-shFlags +++ b/gitflow-shFlags @@ -106,10 +106,10 @@ FLAGS_GETOPT_CMD=${FLAGS_GETOPT_CMD:-getopt} if [ -n "${ZSH_VERSION:-}" ]; then setopt |grep "^shwordsplit$" >/dev/null if [ $? -ne ${FLAGS_TRUE} ]; then - _flags_fatal 'zsh shwordsplit option is required for proper zsh operation' + _flags_fatal 'zsh shwordsplit option is required for proper zsh operation' fi if [ -z "${FLAGS_PARENT:-}" ]; then - _flags_fatal "zsh does not pass \$0 through properly. please declare' \ + _flags_fatal "zsh does not pass \$0 through properly. please declare' \ \"FLAGS_PARENT=\$0\" before calling shFlags" fi fi @@ -139,13 +139,13 @@ ${FLAGS_GETOPT_CMD} >/dev/null 2>&1 case $? in 0) __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_STD} ;; # bsd getopt 2) - # TODO(kward): look into '-T' option to test the internal getopt() version - if [ "`${FLAGS_GETOPT_CMD} --version`" = '-- ' ]; then - __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_STD} - else - __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_ENH} - fi - ;; + # TODO(kward): look into '-T' option to test the internal getopt() version + if [ "`${FLAGS_GETOPT_CMD} --version`" = '-- ' ]; then + __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_STD} + else + __FLAGS_GETOPT_VERS=${__FLAGS_GETOPT_VERS_ENH} + fi + ;; *) _flags_fatal 'unable to determine getopt version' ;; esac @@ -177,17 +177,17 @@ __flags_constants=`set |awk -F= '/^FLAGS_/ || /^__FLAGS_/ {print $1}'` for __flags_const in ${__flags_constants}; do # skip certain flags case ${__flags_const} in - FLAGS_HELP) continue ;; - FLAGS_PARENT) continue ;; + FLAGS_HELP) continue ;; + FLAGS_PARENT) continue ;; esac # set flag readonly if [ -z "${ZSH_VERSION:-}" ]; then - readonly ${__flags_const} + readonly ${__flags_const} else # handle zsh - case ${ZSH_VERSION} in - [123].*) readonly ${__flags_const} ;; - *) readonly -g ${__flags_const} ;; # declare readonly constants globally - esac + case ${ZSH_VERSION} in + [123].*) readonly ${__flags_const} ;; + *) readonly -g ${__flags_const} ;; # declare readonly constants globally + esac fi done unset __flags_const __flags_constants @@ -237,10 +237,10 @@ _flags_fatal() { echo "flags:FATAL $@" >&2; exit ${FLAGS_ERROR}; } _flags_define() { if [ $# -lt 4 ]; then - flags_error='DEFINE error: too few arguments' - flags_return=${FLAGS_ERROR} - _flags_error "${flags_error}" - return ${flags_return} + flags_error='DEFINE error: too few arguments' + flags_return=${FLAGS_ERROR} + _flags_error "${flags_error}" + return ${flags_return} fi _flags_type_=$1 @@ -256,123 +256,123 @@ _flags_define() # check whether the flag name is reserved _flags_itemInList ${_flags_usName_} "${__FLAGS_RESERVED_LIST}" if [ $? -eq ${FLAGS_TRUE} ]; then - flags_error="flag name (${_flags_name_}) is reserved" - _flags_return_=${FLAGS_ERROR} + flags_error="flag name (${_flags_name_}) is reserved" + _flags_return_=${FLAGS_ERROR} fi # require short option for getopt that don't support long options if [ ${_flags_return_} -eq ${FLAGS_TRUE} \ - -a ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} \ - -a "${_flags_short_}" = "${__FLAGS_NULL}" ] + -a ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} \ + -a "${_flags_short_}" = "${__FLAGS_NULL}" ] then - flags_error="short flag required for (${_flags_name_}) on this platform" - _flags_return_=${FLAGS_ERROR} + flags_error="short flag required for (${_flags_name_}) on this platform" + _flags_return_=${FLAGS_ERROR} fi # check for existing long name definition if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then - if _flags_itemInList ${_flags_usName_} ${__flags_definedNames}; then - flags_error="definition for ([no]${_flags_name_}) already exists" - _flags_warn "${flags_error}" - _flags_return_=${FLAGS_FALSE} - fi + if _flags_itemInList ${_flags_usName_} ${__flags_definedNames}; then + flags_error="definition for ([no]${_flags_name_}) already exists" + _flags_warn "${flags_error}" + _flags_return_=${FLAGS_FALSE} + fi fi # check for existing short name definition if [ ${_flags_return_} -eq ${FLAGS_TRUE} \ - -a "${_flags_short_}" != "${__FLAGS_NULL}" ] + -a "${_flags_short_}" != "${__FLAGS_NULL}" ] then - if _flags_itemInList "${_flags_short_}" ${__flags_shortNames}; then - flags_error="flag short name (${_flags_short_}) already defined" - _flags_warn "${flags_error}" - _flags_return_=${FLAGS_FALSE} - fi + if _flags_itemInList "${_flags_short_}" ${__flags_shortNames}; then + flags_error="flag short name (${_flags_short_}) already defined" + _flags_warn "${flags_error}" + _flags_return_=${FLAGS_FALSE} + fi fi # handle default value. note, on several occasions the 'if' portion of an # if/then/else contains just a ':' which does nothing. a binary reversal via # '!' is not done because it does not work on all shells. if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then - case ${_flags_type_} in - ${__FLAGS_TYPE_BOOLEAN}) - if _flags_validBool "${_flags_default_}"; then - case ${_flags_default_} in - true|t|0) _flags_default_=${FLAGS_TRUE} ;; - false|f|1) _flags_default_=${FLAGS_FALSE} ;; - esac - _flags_isNegate ${_flags_name_} - _flags_isNegate_=$? - else - flags_error="invalid default flag value '${_flags_default_}'" - _flags_return_=${FLAGS_ERROR} - fi - ;; - - ${__FLAGS_TYPE_FLOAT}) - if _flags_validFloat "${_flags_default_}"; then - : - else - flags_error="invalid default flag value '${_flags_default_}'" - _flags_return_=${FLAGS_ERROR} - fi - ;; - - ${__FLAGS_TYPE_INTEGER}) - if _flags_validInt "${_flags_default_}"; then - : - else - flags_error="invalid default flag value '${_flags_default_}'" - _flags_return_=${FLAGS_ERROR} - fi - ;; - - ${__FLAGS_TYPE_STRING}) ;; # everything in shell is a valid string - - *) - flags_error="unrecognized flag type '${_flags_type_}'" - _flags_return_=${FLAGS_ERROR} - ;; - esac + case ${_flags_type_} in + ${__FLAGS_TYPE_BOOLEAN}) + if _flags_validBool "${_flags_default_}"; then + case ${_flags_default_} in + true|t|0) _flags_default_=${FLAGS_TRUE} ;; + false|f|1) _flags_default_=${FLAGS_FALSE} ;; + esac + _flags_isNegate ${_flags_name_} + _flags_isNegate_=$? + else + flags_error="invalid default flag value '${_flags_default_}'" + _flags_return_=${FLAGS_ERROR} + fi + ;; + + ${__FLAGS_TYPE_FLOAT}) + if _flags_validFloat "${_flags_default_}"; then + : + else + flags_error="invalid default flag value '${_flags_default_}'" + _flags_return_=${FLAGS_ERROR} + fi + ;; + + ${__FLAGS_TYPE_INTEGER}) + if _flags_validInt "${_flags_default_}"; then + : + else + flags_error="invalid default flag value '${_flags_default_}'" + _flags_return_=${FLAGS_ERROR} + fi + ;; + + ${__FLAGS_TYPE_STRING}) ;; # everything in shell is a valid string + + *) + flags_error="unrecognized flag type '${_flags_type_}'" + _flags_return_=${FLAGS_ERROR} + ;; + esac fi if [ ${_flags_return_} -eq ${FLAGS_TRUE} ]; then - # store flag information - eval "FLAGS_${_flags_usName_}='${_flags_default_}'" - eval "__flags_${_flags_usName_}_${__FLAGS_INFO_TYPE}=${_flags_type_}" - eval "__flags_${_flags_usName_}_${__FLAGS_INFO_DEFAULT}=\ + # store flag information + eval "FLAGS_${_flags_usName_}='${_flags_default_}'" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_TYPE}=${_flags_type_}" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_DEFAULT}=\ \"${_flags_default_}\"" - eval "__flags_${_flags_usName_}_${__FLAGS_INFO_HELP}=\"${_flags_help_}\"" - eval "__flags_${_flags_usName_}_${__FLAGS_INFO_SHORT}='${_flags_short_}'" - - # append flag names to name lists - __flags_shortNames="${__flags_shortNames}${_flags_short_} " - __flags_longNames="${__flags_longNames}`_flags_removeExclamationName ${_flags_name_}` " - if [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} \ - -a ${_flags_isNegate_} -eq ${FLAGS_TRUE} ]; then - __flags_boolNames="${__flags_boolNames}no${_flags_name_} " - fi - - # append flag names to defined names for later validation checks - __flags_definedNames="${__flags_definedNames}${_flags_usName_} " - if [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ]; then - if [ ${_flags_isNegate_} -eq ${FLAGS_TRUE} ]; then - __flags_definedNames="${__flags_definedNames}no${_flags_usName_} " - fi - fi - - # append flag names to nonegateNames names for later validation checks - __flags_definedNames="${__flags_definedNames}${_flags_usName_} " - if [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ]; then - if [ ${_flags_isNegate_} -eq ${FLAGS_FALSE} ]; then - __flags_nonegateNames="${__flags_nonegateNames}`_flags_removeExclamationName ${_flags_name_}` " - fi - fi + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_HELP}=\"${_flags_help_}\"" + eval "__flags_${_flags_usName_}_${__FLAGS_INFO_SHORT}='${_flags_short_}'" + + # append flag names to name lists + __flags_shortNames="${__flags_shortNames}${_flags_short_} " + __flags_longNames="${__flags_longNames}`_flags_removeExclamationName ${_flags_name_}` " + if [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} \ + -a ${_flags_isNegate_} -eq ${FLAGS_TRUE} ]; then + __flags_boolNames="${__flags_boolNames}no${_flags_name_} " + fi + + # append flag names to defined names for later validation checks + __flags_definedNames="${__flags_definedNames}${_flags_usName_} " + if [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ]; then + if [ ${_flags_isNegate_} -eq ${FLAGS_TRUE} ]; then + __flags_definedNames="${__flags_definedNames}no${_flags_usName_} " + fi + fi + + # append flag names to nonegateNames names for later validation checks + __flags_definedNames="${__flags_definedNames}${_flags_usName_} " + if [ ${_flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ]; then + if [ ${_flags_isNegate_} -eq ${FLAGS_FALSE} ]; then + __flags_nonegateNames="${__flags_nonegateNames}`_flags_removeExclamationName ${_flags_name_}` " + fi + fi fi flags_return=${_flags_return_} unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ \ - _flags_short_ _flags_type_ _flags_usName_ + _flags_short_ _flags_type_ _flags_usName_ [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_error "${flags_error}" return ${flags_return} } @@ -398,13 +398,13 @@ _flags_removeExclamationName() { _flags_opt_=$1 if _flags_isNegate "${_flags_opt_}"; then - echo ${_flags_opt_} + echo ${_flags_opt_} else - if _flags_useBuiltin; then - echo ${_flags_opt_%!*} - else - echo ${_flags_opt_}|sed 's/!$//' - fi + if _flags_useBuiltin; then + echo ${_flags_opt_%!*} + else + echo ${_flags_opt_}|sed 's/!$//' + fi fi unset _flags_opt_ return ${FLAGS_TRUE} @@ -419,8 +419,8 @@ _flags_removeExclamationName() _flags_isNegate() { case $1 in - *!) flags_return=${FLAGS_FALSE} ;; - *) flags_return=${FLAGS_TRUE} ;; + *!) flags_return=${FLAGS_FALSE} ;; + *) flags_return=${FLAGS_TRUE} ;; esac return ${flags_return} } @@ -444,34 +444,34 @@ _flags_genOptStr() _flags_opts_='' for _flags_name_ in ${__flags_longNames}; do - _flags_usName_=`_flags_removeExclamationName ${_flags_name_}` - _flags_usName_=`_flags_underscoreName ${_flags_usName_}` - _flags_type_=`_flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE}` - [ $? -eq ${FLAGS_TRUE} ] || _flags_fatal 'call to _flags_type_ failed' - case ${_flags_optStrType_} in - ${__FLAGS_OPTSTR_SHORT}) - _flags_shortName_=`_flags_getFlagInfo \ - ${_flags_usName_} ${__FLAGS_INFO_SHORT}` - if [ "${_flags_shortName_}" != "${__FLAGS_NULL}" ]; then - _flags_opts_="${_flags_opts_}${_flags_shortName_}" - # getopt needs a trailing ':' to indicate a required argument - [ ${_flags_type_} -ne ${__FLAGS_TYPE_BOOLEAN} ] && \ - _flags_opts_="${_flags_opts_}:" - fi - ;; - - ${__FLAGS_OPTSTR_LONG}) - _flags_opts_="${_flags_opts_:+${_flags_opts_},}`_flags_removeExclamationName ${_flags_name_}`" - # getopt needs a trailing ':' to indicate a required argument - [ ${_flags_type_} -ne ${__FLAGS_TYPE_BOOLEAN} ] && \ - _flags_opts_="${_flags_opts_}:" - ;; - esac + _flags_usName_=`_flags_removeExclamationName ${_flags_name_}` + _flags_usName_=`_flags_underscoreName ${_flags_usName_}` + _flags_type_=`_flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE}` + [ $? -eq ${FLAGS_TRUE} ] || _flags_fatal 'call to _flags_type_ failed' + case ${_flags_optStrType_} in + ${__FLAGS_OPTSTR_SHORT}) + _flags_shortName_=`_flags_getFlagInfo \ + ${_flags_usName_} ${__FLAGS_INFO_SHORT}` + if [ "${_flags_shortName_}" != "${__FLAGS_NULL}" ]; then + _flags_opts_="${_flags_opts_}${_flags_shortName_}" + # getopt needs a trailing ':' to indicate a required argument + [ ${_flags_type_} -ne ${__FLAGS_TYPE_BOOLEAN} ] && \ + _flags_opts_="${_flags_opts_}:" + fi + ;; + + ${__FLAGS_OPTSTR_LONG}) + _flags_opts_="${_flags_opts_:+${_flags_opts_},}`_flags_removeExclamationName ${_flags_name_}`" + # getopt needs a trailing ':' to indicate a required argument + [ ${_flags_type_} -ne ${__FLAGS_TYPE_BOOLEAN} ] && \ + _flags_opts_="${_flags_opts_}:" + ;; + esac done echo "${_flags_opts_}" unset _flags_name_ _flags_opts_ _flags_optStrType_ _flags_shortName_ \ - _flags_type_ _flags_usName_ + _flags_type_ _flags_usName_ return ${FLAGS_TRUE} } @@ -495,30 +495,30 @@ _flags_getFlagInfo() _flags_strToEval_="_flags_infoValue_=\"\${${_flags_infoVar_}:-}\"" eval "${_flags_strToEval_}" if [ -n "${_flags_infoValue_}" ]; then - flags_return=${FLAGS_TRUE} + flags_return=${FLAGS_TRUE} else - # see if the _flags_gFI_usName_ variable is a string as strings can be - # empty... - # note: the DRY principle would say to have this function call itself for - # the next three lines, but doing so results in an infinite loop as an - # invalid _flags_name_ will also not have the associated _type variable. - # Because it doesn't (it will evaluate to an empty string) the logic will - # try to find the _type variable of the _type variable, and so on. Not so - # good ;-) - _flags_typeVar_="__flags_${_flags_gFI_usName_}_${__FLAGS_INFO_TYPE}" - _flags_strToEval_="_flags_typeValue_=\"\${${_flags_typeVar_}:-}\"" - eval "${_flags_strToEval_}" - if [ "${_flags_typeValue_}" = "${__FLAGS_TYPE_STRING}" ]; then - flags_return=${FLAGS_TRUE} - else - flags_return=${FLAGS_ERROR} - flags_error="missing flag info variable (${_flags_infoVar_})" - fi + # see if the _flags_gFI_usName_ variable is a string as strings can be + # empty... + # note: the DRY principle would say to have this function call itself for + # the next three lines, but doing so results in an infinite loop as an + # invalid _flags_name_ will also not have the associated _type variable. + # Because it doesn't (it will evaluate to an empty string) the logic will + # try to find the _type variable of the _type variable, and so on. Not so + # good ;-) + _flags_typeVar_="__flags_${_flags_gFI_usName_}_${__FLAGS_INFO_TYPE}" + _flags_strToEval_="_flags_typeValue_=\"\${${_flags_typeVar_}:-}\"" + eval "${_flags_strToEval_}" + if [ "${_flags_typeValue_}" = "${__FLAGS_TYPE_STRING}" ]; then + flags_return=${FLAGS_TRUE} + else + flags_return=${FLAGS_ERROR} + flags_error="missing flag info variable (${_flags_infoVar_})" + fi fi echo "${_flags_infoValue_}" unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ \ - _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ + _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_error "${flags_error}" return ${flags_return} } @@ -539,12 +539,12 @@ _flags_itemInList() { _flags_list_=" ${*:-} " case ${_flags_list_} in - *\ ${_flags_str_}\ *) - flags_return=$FLAGS_TRUE - ;; - *) - flags_return=$FLAGS_FALSE - ;; + *\ ${_flags_str_}\ *) + flags_return=$FLAGS_TRUE + ;; + *) + flags_return=$FLAGS_FALSE + ;; esac unset _flags_str_ _flags_list_ @@ -558,17 +558,17 @@ _flags_itemInList() { _flags_columns() { if [ -z "${__flags_columns}" ]; then - # determine the value and store it - if eval stty size >/dev/null 2>&1; then - # stty size worked :-) - set -- `stty size` - __flags_columns=$2 - elif eval tput cols >/dev/null 2>&1; then - set -- `tput cols` - __flags_columns=$1 - else - __flags_columns=80 # default terminal width - fi + # determine the value and store it + if eval stty size >/dev/null 2>&1; then + # stty size worked :-) + set -- `stty size` + __flags_columns=$2 + elif eval tput cols >/dev/null 2>&1; then + set -- `tput cols` + __flags_columns=$1 + else + __flags_columns=80 # default terminal width + fi fi echo ${__flags_columns} } @@ -585,9 +585,9 @@ _flags_validBool() flags_return=${FLAGS_TRUE} case "${_flags_bool_}" in - true|t|0) ;; - false|f|1) ;; - *) flags_return=${FLAGS_FALSE} ;; + true|t|0) ;; + false|f|1) ;; + *) flags_return=${FLAGS_FALSE} ;; esac unset _flags_bool_ @@ -607,29 +607,29 @@ _flags_validFloat() _flags_float_=$1 if _flags_validInt ${_flags_float_}; then - flags_return=${FLAGS_TRUE} + flags_return=${FLAGS_TRUE} elif _flags_useBuiltin; then - _flags_float_whole_=${_flags_float_%.*} - _flags_float_fraction_=${_flags_float_#*.} - if _flags_validInt ${_flags_float_whole_:-0} -a \ - _flags_validInt ${_flags_float_fraction_}; then - flags_return=${FLAGS_TRUE} - fi - unset _flags_float_whole_ _flags_float_fraction_ + _flags_float_whole_=${_flags_float_%.*} + _flags_float_fraction_=${_flags_float_#*.} + if _flags_validInt ${_flags_float_whole_:-0} -a \ + _flags_validInt ${_flags_float_fraction_}; then + flags_return=${FLAGS_TRUE} + fi + unset _flags_float_whole_ _flags_float_fraction_ else - flags_return=${FLAGS_TRUE} - case ${_flags_float_} in - -*) # negative floats - _flags_test_=`${FLAGS_EXPR_CMD} -- "${_flags_float_}" :\ - '\(-[0-9]*\.[0-9]*\)'` - ;; - *) # positive floats - _flags_test_=`${FLAGS_EXPR_CMD} -- "${_flags_float_}" :\ - '\([0-9]*\.[0-9]*\)'` - ;; - esac - [ "${_flags_test_}" != "${_flags_float_}" ] && flags_return=${FLAGS_FALSE} - unset _flags_test_ + flags_return=${FLAGS_TRUE} + case ${_flags_float_} in + -*) # negative floats + _flags_test_=`${FLAGS_EXPR_CMD} -- "${_flags_float_}" :\ + '\(-[0-9]*\.[0-9]*\)'` + ;; + *) # positive floats + _flags_test_=`${FLAGS_EXPR_CMD} -- "${_flags_float_}" :\ + '\([0-9]*\.[0-9]*\)'` + ;; + esac + [ "${_flags_test_}" != "${_flags_float_}" ] && flags_return=${FLAGS_FALSE} + unset _flags_test_ fi unset _flags_float_ _flags_float_whole_ _flags_float_fraction_ @@ -649,19 +649,19 @@ _flags_validInt() _flags_int_=$1 case ${_flags_int_} in - -*.*) ;; # ignore negative floats (we'll invalidate them later) - -*) # strip possible leading negative sign - if _flags_useBuiltin; then - _flags_int_=${_flags_int_#-} - else - _flags_int_=`${FLAGS_EXPR_CMD} -- "${_flags_int_}" : '-\([0-9][0-9]*\)'` - fi - ;; + -*.*) ;; # ignore negative floats (we'll invalidate them later) + -*) # strip possible leading negative sign + if _flags_useBuiltin; then + _flags_int_=${_flags_int_#-} + else + _flags_int_=`${FLAGS_EXPR_CMD} -- "${_flags_int_}" : '-\([0-9][0-9]*\)'` + fi + ;; esac case ${_flags_int_} in - *[!0-9]*) flags_return=${FLAGS_FALSE} ;; - *) flags_return=${FLAGS_TRUE} ;; + *[!0-9]*) flags_return=${FLAGS_FALSE} ;; + *) flags_return=${FLAGS_TRUE} ;; esac unset _flags_int_ @@ -684,23 +684,23 @@ _flags_getoptStandard() # check for spaces in passed options for _flags_opt_ in "$@"; do - # note: the silliness with the x's is purely for ksh93 on Ubuntu 6.06 - _flags_match_=`echo "x${_flags_opt_}x" |sed 's/ //g'` - if [ "${_flags_match_}" != "x${_flags_opt_}x" ]; then - flags_error='the available getopt does not support spaces in options' - flags_return=${FLAGS_ERROR} - break - fi + # note: the silliness with the x's is purely for ksh93 on Ubuntu 6.06 + _flags_match_=`echo "x${_flags_opt_}x" |sed 's/ //g'` + if [ "${_flags_match_}" != "x${_flags_opt_}x" ]; then + flags_error='the available getopt does not support spaces in options' + flags_return=${FLAGS_ERROR} + break + fi done if [ ${flags_return} -eq ${FLAGS_TRUE} ]; then - __flags_opts=`getopt ${_flags_shortOpts_} $@ 2>&1` - _flags_rtrn_=$? - if [ ${_flags_rtrn_} -ne ${FLAGS_TRUE} ]; then - _flags_warn "${__flags_opts}" - flags_error='unable to parse provided options with getopt.' - flags_return=${FLAGS_ERROR} - fi + __flags_opts=`getopt ${_flags_shortOpts_} $@ 2>&1` + _flags_rtrn_=$? + if [ ${_flags_rtrn_} -ne ${FLAGS_TRUE} ]; then + _flags_warn "${__flags_opts}" + flags_error='unable to parse provided options with getopt.' + flags_return=${FLAGS_ERROR} + fi fi unset _flags_match_ _flags_opt_ _flags_rtrn_ _flags_shortOpts_ @@ -721,18 +721,18 @@ _flags_getoptEnhanced() flags_return=${FLAGS_TRUE} _flags_shortOpts_=`_flags_genOptStr ${__FLAGS_OPTSTR_SHORT}` _flags_boolOpts_=`echo "${__flags_boolNames}" \ - |sed 's/^ *//;s/ *$//;s/ /,/g'` + |sed 's/^ *//;s/ *$//;s/ /,/g'` _flags_longOpts_=`_flags_genOptStr ${__FLAGS_OPTSTR_LONG}` __flags_opts=`${FLAGS_GETOPT_CMD} \ - -o ${_flags_shortOpts_} \ - -l "${_flags_longOpts_},${_flags_boolOpts_}" \ - -- "$@" 2>&1` + -o ${_flags_shortOpts_} \ + -l "${_flags_longOpts_},${_flags_boolOpts_}" \ + -- "$@" 2>&1` _flags_rtrn_=$? if [ ${_flags_rtrn_} -ne ${FLAGS_TRUE} ]; then - _flags_warn "${__flags_opts}" - flags_error='unable to parse provided options with getopt.' - flags_return=${FLAGS_ERROR} + _flags_warn "${__flags_opts}" + flags_error='unable to parse provided options with getopt.' + flags_return=${FLAGS_ERROR} fi unset _flags_boolOpts_ _flags_longOpts_ _flags_rtrn_ _flags_shortOpts_ @@ -758,10 +758,10 @@ _flags_parseGetopt() flags_return=${FLAGS_TRUE} if [ ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} ]; then - set -- $@ + set -- $@ else - # note the quotes around the `$@' -- they are essential! - eval set -- "$@" + # note the quotes around the `$@' -- they are essential! + eval set -- "$@" fi # Provide user with the number of arguments to shift by later. @@ -773,139 +773,139 @@ _flags_parseGetopt() # handle options. note options with values must do an additional shift while true; do - _flags_opt_=$1 - _flags_arg_=${2:-} - _flags_type_=${__FLAGS_TYPE_NONE} - _flags_name_='' - - # determine long flag name - case "${_flags_opt_}" in - --) shift; break ;; # discontinue option parsing - - --*) # long option - if _flags_useBuiltin; then - _flags_opt_=${_flags_opt_#*--} - else - _flags_opt_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : '--\(.*\)'` - fi - _flags_len_=${__FLAGS_LEN_LONG} - if _flags_itemInList "${_flags_opt_}" ${__flags_longNames}; then - _flags_name_=${_flags_opt_} - else - # check for negated long boolean version - if _flags_itemInList "${_flags_opt_}" ${__flags_boolNames}; then - if _flags_useBuiltin; then - _flags_name_=${_flags_opt_#*no} - else - _flags_name_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : 'no\(.*\)'` - fi - _flags_type_=${__FLAGS_TYPE_BOOLEAN} - _flags_arg_=${__FLAGS_NULL} - fi - fi - ;; - - -*) # short option - if _flags_useBuiltin; then - _flags_opt_=${_flags_opt_#*-} - else - _flags_opt_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : '-\(.*\)'` - fi - _flags_len_=${__FLAGS_LEN_SHORT} - if _flags_itemInList "${_flags_opt_}" ${__flags_shortNames}; then - # yes. match short name to long name. note purposeful off-by-one - # (too high) with awk calculations. - _flags_pos_=`echo "${__flags_shortNames}" \ - |awk 'BEGIN{RS=" ";rn=0}$0==e{rn=NR}END{print rn}' \ - e=${_flags_opt_}` - _flags_name_=`echo "${__flags_longNames}" \ - |awk 'BEGIN{RS=" "}rn==NR{print $0}' rn="${_flags_pos_}"` - fi - ;; - esac - - # die if the flag was unrecognized - if [ -z "${_flags_name_}" ]; then - flags_error="unrecognized option (${_flags_opt_})" - flags_return=${FLAGS_ERROR} - break - fi - - # set new flag value - _flags_usName_=`_flags_removeExclamationName ${_flags_name_}` - _flags_usName_=`_flags_underscoreName ${_flags_usName_}` - [ ${_flags_type_} -eq ${__FLAGS_TYPE_NONE} ] && \ - _flags_type_=`_flags_getFlagInfo \ - "${_flags_usName_}" ${__FLAGS_INFO_TYPE}` - case ${_flags_type_} in - ${__FLAGS_TYPE_BOOLEAN}) - if [ ${_flags_len_} -eq ${__FLAGS_LEN_LONG} ]; then - if [ "${_flags_arg_}" != "${__FLAGS_NULL}" ]; then - eval "FLAGS_${_flags_usName_}=${FLAGS_TRUE}" - else - eval "FLAGS_${_flags_usName_}=${FLAGS_FALSE}" - fi - else - _flags_strToEval_="_flags_val_=\ + _flags_opt_=$1 + _flags_arg_=${2:-} + _flags_type_=${__FLAGS_TYPE_NONE} + _flags_name_='' + + # determine long flag name + case "${_flags_opt_}" in + --) shift; break ;; # discontinue option parsing + + --*) # long option + if _flags_useBuiltin; then + _flags_opt_=${_flags_opt_#*--} + else + _flags_opt_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : '--\(.*\)'` + fi + _flags_len_=${__FLAGS_LEN_LONG} + if _flags_itemInList "${_flags_opt_}" ${__flags_longNames}; then + _flags_name_=${_flags_opt_} + else + # check for negated long boolean version + if _flags_itemInList "${_flags_opt_}" ${__flags_boolNames}; then + if _flags_useBuiltin; then + _flags_name_=${_flags_opt_#*no} + else + _flags_name_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : 'no\(.*\)'` + fi + _flags_type_=${__FLAGS_TYPE_BOOLEAN} + _flags_arg_=${__FLAGS_NULL} + fi + fi + ;; + + -*) # short option + if _flags_useBuiltin; then + _flags_opt_=${_flags_opt_#*-} + else + _flags_opt_=`${FLAGS_EXPR_CMD} -- "${_flags_opt_}" : '-\(.*\)'` + fi + _flags_len_=${__FLAGS_LEN_SHORT} + if _flags_itemInList "${_flags_opt_}" ${__flags_shortNames}; then + # yes. match short name to long name. note purposeful off-by-one + # (too high) with awk calculations. + _flags_pos_=`echo "${__flags_shortNames}" \ + |awk 'BEGIN{RS=" ";rn=0}$0==e{rn=NR}END{print rn}' \ + e=${_flags_opt_}` + _flags_name_=`echo "${__flags_longNames}" \ + |awk 'BEGIN{RS=" "}rn==NR{print $0}' rn="${_flags_pos_}"` + fi + ;; + esac + + # die if the flag was unrecognized + if [ -z "${_flags_name_}" ]; then + flags_error="unrecognized option (${_flags_opt_})" + flags_return=${FLAGS_ERROR} + break + fi + + # set new flag value + _flags_usName_=`_flags_removeExclamationName ${_flags_name_}` + _flags_usName_=`_flags_underscoreName ${_flags_usName_}` + [ ${_flags_type_} -eq ${__FLAGS_TYPE_NONE} ] && \ + _flags_type_=`_flags_getFlagInfo \ + "${_flags_usName_}" ${__FLAGS_INFO_TYPE}` + case ${_flags_type_} in + ${__FLAGS_TYPE_BOOLEAN}) + if [ ${_flags_len_} -eq ${__FLAGS_LEN_LONG} ]; then + if [ "${_flags_arg_}" != "${__FLAGS_NULL}" ]; then + eval "FLAGS_${_flags_usName_}=${FLAGS_TRUE}" + else + eval "FLAGS_${_flags_usName_}=${FLAGS_FALSE}" + fi + else + _flags_strToEval_="_flags_val_=\ \${__flags_${_flags_usName_}_${__FLAGS_INFO_DEFAULT}}" - eval "${_flags_strToEval_}" - if [ ${_flags_val_} -eq ${FLAGS_FALSE} ]; then - eval "FLAGS_${_flags_usName_}=${FLAGS_TRUE}" - else - eval "FLAGS_${_flags_usName_}=${FLAGS_FALSE}" - fi - fi - ;; - - ${__FLAGS_TYPE_FLOAT}) - if _flags_validFloat "${_flags_arg_}"; then - eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" - else - flags_error="invalid float value (${_flags_arg_})" - flags_return=${FLAGS_ERROR} - break - fi - ;; - - ${__FLAGS_TYPE_INTEGER}) - if _flags_validInt "${_flags_arg_}"; then - eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" - else - flags_error="invalid integer value (${_flags_arg_})" - flags_return=${FLAGS_ERROR} - break - fi - ;; - - ${__FLAGS_TYPE_STRING}) - eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" - ;; - esac - - # handle special case help flag - if [ "${_flags_usName_}" = 'help' ]; then - if [ ${FLAGS_help} -eq ${FLAGS_TRUE} ]; then - flags_help - flags_error='help requested' - flags_return=${FLAGS_TRUE} - break - fi - fi - - # shift the option and non-boolean arguements out. - shift - [ ${_flags_type_} != ${__FLAGS_TYPE_BOOLEAN} ] && shift + eval "${_flags_strToEval_}" + if [ ${_flags_val_} -eq ${FLAGS_FALSE} ]; then + eval "FLAGS_${_flags_usName_}=${FLAGS_TRUE}" + else + eval "FLAGS_${_flags_usName_}=${FLAGS_FALSE}" + fi + fi + ;; + + ${__FLAGS_TYPE_FLOAT}) + if _flags_validFloat "${_flags_arg_}"; then + eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" + else + flags_error="invalid float value (${_flags_arg_})" + flags_return=${FLAGS_ERROR} + break + fi + ;; + + ${__FLAGS_TYPE_INTEGER}) + if _flags_validInt "${_flags_arg_}"; then + eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" + else + flags_error="invalid integer value (${_flags_arg_})" + flags_return=${FLAGS_ERROR} + break + fi + ;; + + ${__FLAGS_TYPE_STRING}) + eval "FLAGS_${_flags_usName_}='${_flags_arg_}'" + ;; + esac + + # handle special case help flag + if [ "${_flags_usName_}" = 'help' ]; then + if [ ${FLAGS_help} -eq ${FLAGS_TRUE} ]; then + flags_help + flags_error='help requested' + flags_return=${FLAGS_TRUE} + break + fi + fi + + # shift the option and non-boolean arguements out. + shift + [ ${_flags_type_} != ${__FLAGS_TYPE_BOOLEAN} ] && shift done # give user back non-flag arguments FLAGS_ARGV='' while [ $# -gt 0 ]; do - FLAGS_ARGV="${FLAGS_ARGV:+${FLAGS_ARGV} }'$1'" - shift + FLAGS_ARGV="${FLAGS_ARGV:+${FLAGS_ARGV} }'$1'" + shift done unset _flags_arg_ _flags_len_ _flags_name_ _flags_opt_ _flags_pos_ \ - _flags_strToEval_ _flags_type_ _flags_usName_ _flags_val_ + _flags_strToEval_ _flags_type_ _flags_usName_ _flags_val_ return ${flags_return} } @@ -920,17 +920,17 @@ _flags_parseGetopt() _flags_math() { if [ $# -eq 0 ]; then - flags_return=${FLAGS_FALSE} + flags_return=${FLAGS_FALSE} elif _flags_useBuiltin; then - # Variable assignment is needed as workaround for Solaris Bourne shell, - # which cannot parse a bare $((expression)). - _flags_expr_='$(($@))' - eval echo ${_flags_expr_} - flags_return=$? - unset _flags_expr_ + # Variable assignment is needed as workaround for Solaris Bourne shell, + # which cannot parse a bare $((expression)). + _flags_expr_='$(($@))' + eval echo ${_flags_expr_} + flags_return=$? + unset _flags_expr_ else - eval expr $@ - flags_return=$? + eval expr $@ + flags_return=$? fi return ${flags_return} @@ -949,11 +949,11 @@ _flags_strlen() _flags_str_=${1:-} if [ -z "${_flags_str_}" ]; then - flags_output=0 + flags_output=0 elif _flags_useBuiltin; then - flags_output=${#_flags_str_} + flags_output=${#_flags_str_} else - flags_output=`${FLAGS_EXPR_CMD} -- "${_flags_str_}" : '.*'` + flags_output=`${FLAGS_EXPR_CMD} -- "${_flags_str_}" : '.*'` fi flags_return=$? @@ -1006,25 +1006,25 @@ FLAGS() { # define a standard 'help' flag if one isn't already defined [ -z "${__flags_help_type:-}" ] && \ - DEFINE_boolean 'help!' false 'show this help' 'h' + DEFINE_boolean 'help!' false 'show this help' 'h' # parse options if [ $# -gt 0 ]; then - if [ ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} ]; then - _flags_getoptStandard "$@" - else - _flags_getoptEnhanced "$@" - fi - flags_return=$? + if [ ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} ]; then + _flags_getoptStandard "$@" + else + _flags_getoptEnhanced "$@" + fi + flags_return=$? else - # nothing passed; won't bother running getopt - __flags_opts='--' - flags_return=${FLAGS_TRUE} + # nothing passed; won't bother running getopt + __flags_opts='--' + flags_return=${FLAGS_TRUE} fi if [ ${flags_return} -eq ${FLAGS_TRUE} ]; then - _flags_parseGetopt $# "${__flags_opts}" - flags_return=$? + _flags_parseGetopt $# "${__flags_opts}" + flags_return=$? fi [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_fatal "${flags_error}" @@ -1049,11 +1049,11 @@ flags_getoptInfo() # shell info if [ -n "${BASH_VERSION:-}" ]; then - _flags_debug 'shell: bash' - _flags_debug "BASH_VERSION: ${BASH_VERSION}" + _flags_debug 'shell: bash' + _flags_debug "BASH_VERSION: ${BASH_VERSION}" elif [ -n "${ZSH_VERSION:-}" ]; then - _flags_debug 'shell: zsh' - _flags_debug "ZSH_VERSION: ${ZSH_VERSION}" + _flags_debug 'shell: zsh' + _flags_debug "ZSH_VERSION: ${ZSH_VERSION}" fi # getopt info @@ -1101,89 +1101,89 @@ flags_getoptIsStd() flags_help() { if [ -n "${FLAGS_HELP:-}" ]; then - echo "${FLAGS_HELP}" >&2 + echo "${FLAGS_HELP}" >&2 else - echo "USAGE: ${FLAGS_PARENT:-$0} [flags] args" >&2 + echo "USAGE: ${FLAGS_PARENT:-$0} [flags] args" >&2 fi if [ -n "${__flags_longNames}" ]; then - echo 'flags:' >&2 - for flags_name_ in ${__flags_longNames}; do - flags_flagStr_='' - flags_boolStr_='' - flags_usName_=`_flags_underscoreName ${flags_name_}` - - flags_default_=`_flags_getFlagInfo \ - "${flags_usName_}" ${__FLAGS_INFO_DEFAULT}` - flags_help_=`_flags_getFlagInfo \ - "${flags_usName_}" ${__FLAGS_INFO_HELP}` - flags_short_=`_flags_getFlagInfo \ - "${flags_usName_}" ${__FLAGS_INFO_SHORT}` - flags_type_=`_flags_getFlagInfo \ - "${flags_usName_}" ${__FLAGS_INFO_TYPE}` - - [ "${flags_short_}" != "${__FLAGS_NULL}" ] && \ - flags_flagStr_="-${flags_short_}" - - if [ ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_ENH} ]; then - [ "${flags_short_}" != "${__FLAGS_NULL}" ] && \ - flags_flagStr_="${flags_flagStr_}," - # add [no] to long boolean flag names, except the 'help' flag - if [ ${flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ]; then - _flags_itemInList "${flags_name_}" ${__flags_nonegateNames} - if [ $? -eq ${FLAGS_FALSE} ]; then - flags_boolStr_='[no]' - fi - fi - flags_flagStr_="${flags_flagStr_}--${flags_boolStr_}${flags_name_}:" - fi - - case ${flags_type_} in - ${__FLAGS_TYPE_BOOLEAN}) - if [ ${flags_default_} -eq ${FLAGS_TRUE} ]; then - flags_defaultStr_='true' - else - flags_defaultStr_='false' - fi - ;; - ${__FLAGS_TYPE_FLOAT}|${__FLAGS_TYPE_INTEGER}) - flags_defaultStr_=${flags_default_} ;; - ${__FLAGS_TYPE_STRING}) flags_defaultStr_="'${flags_default_}'" ;; - esac - flags_defaultStr_="(default: ${flags_defaultStr_})" - - flags_helpStr_=" ${flags_flagStr_} ${flags_help_} ${flags_defaultStr_}" - _flags_strlen "${flags_helpStr_}" >/dev/null - flags_helpStrLen_=${flags_output} - flags_columns_=`_flags_columns` - - if [ ${flags_helpStrLen_} -lt ${flags_columns_} ]; then - echo "${flags_helpStr_}" >&2 - else - echo " ${flags_flagStr_} ${flags_help_}" >&2 - # note: the silliness with the x's is purely for ksh93 on Ubuntu 6.06 - # because it doesn't like empty strings when used in this manner. - flags_emptyStr_="`echo \"x${flags_flagStr_}x\" \ - |awk '{printf "%"length($0)-2"s", ""}'`" - flags_helpStr_=" ${flags_emptyStr_} ${flags_defaultStr_}" - _flags_strlen "${flags_helpStr_}" >/dev/null - flags_helpStrLen_=${flags_output} - - if [ ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_STD} \ - -o ${flags_helpStrLen_} -lt ${flags_columns_} ]; then - # indented to match help string - echo "${flags_helpStr_}" >&2 - else - # indented four from left to allow for longer defaults as long flag - # names might be used too, making things too long - echo " ${flags_defaultStr_}" >&2 - fi - fi - done + echo 'flags:' >&2 + for flags_name_ in ${__flags_longNames}; do + flags_flagStr_='' + flags_boolStr_='' + flags_usName_=`_flags_underscoreName ${flags_name_}` + + flags_default_=`_flags_getFlagInfo \ + "${flags_usName_}" ${__FLAGS_INFO_DEFAULT}` + flags_help_=`_flags_getFlagInfo \ + "${flags_usName_}" ${__FLAGS_INFO_HELP}` + flags_short_=`_flags_getFlagInfo \ + "${flags_usName_}" ${__FLAGS_INFO_SHORT}` + flags_type_=`_flags_getFlagInfo \ + "${flags_usName_}" ${__FLAGS_INFO_TYPE}` + + [ "${flags_short_}" != "${__FLAGS_NULL}" ] && \ + flags_flagStr_="-${flags_short_}" + + if [ ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_ENH} ]; then + [ "${flags_short_}" != "${__FLAGS_NULL}" ] && \ + flags_flagStr_="${flags_flagStr_}," + # add [no] to long boolean flag names, except the 'help' flag + if [ ${flags_type_} -eq ${__FLAGS_TYPE_BOOLEAN} ]; then + _flags_itemInList "${flags_name_}" ${__flags_nonegateNames} + if [ $? -eq ${FLAGS_FALSE} ]; then + flags_boolStr_='[no]' + fi + fi + flags_flagStr_="${flags_flagStr_}--${flags_boolStr_}${flags_name_}:" + fi + + case ${flags_type_} in + ${__FLAGS_TYPE_BOOLEAN}) + if [ ${flags_default_} -eq ${FLAGS_TRUE} ]; then + flags_defaultStr_='true' + else + flags_defaultStr_='false' + fi + ;; + ${__FLAGS_TYPE_FLOAT}|${__FLAGS_TYPE_INTEGER}) + flags_defaultStr_=${flags_default_} ;; + ${__FLAGS_TYPE_STRING}) flags_defaultStr_="'${flags_default_}'" ;; + esac + flags_defaultStr_="(default: ${flags_defaultStr_})" + + flags_helpStr_=" ${flags_flagStr_} ${flags_help_} ${flags_defaultStr_}" + _flags_strlen "${flags_helpStr_}" >/dev/null + flags_helpStrLen_=${flags_output} + flags_columns_=`_flags_columns` + + if [ ${flags_helpStrLen_} -lt ${flags_columns_} ]; then + echo "${flags_helpStr_}" >&2 + else + echo " ${flags_flagStr_} ${flags_help_}" >&2 + # note: the silliness with the x's is purely for ksh93 on Ubuntu 6.06 + # because it doesn't like empty strings when used in this manner. + flags_emptyStr_="`echo \"x${flags_flagStr_}x\" \ + |awk '{printf "%"length($0)-2"s", ""}'`" + flags_helpStr_=" ${flags_emptyStr_} ${flags_defaultStr_}" + _flags_strlen "${flags_helpStr_}" >/dev/null + flags_helpStrLen_=${flags_output} + + if [ ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_STD} \ + -o ${flags_helpStrLen_} -lt ${flags_columns_} ]; then + # indented to match help string + echo "${flags_helpStr_}" >&2 + else + # indented four from left to allow for longer defaults as long flag + # names might be used too, making things too long + echo " ${flags_defaultStr_}" >&2 + fi + fi + done fi unset flags_boolStr_ flags_default_ flags_defaultStr_ flags_emptyStr_ \ - flags_flagStr_ flags_help_ flags_helpStr flags_helpStrLen flags_name_ \ - flags_columns_ flags_short_ flags_type_ flags_usName_ + flags_flagStr_ flags_help_ flags_helpStr flags_helpStrLen flags_name_ \ + flags_columns_ flags_short_ flags_type_ flags_usName_ return ${FLAGS_TRUE} } @@ -1196,19 +1196,19 @@ flags_help() flags_reset() { for flags_name_ in ${__flags_longNames}; do - flags_usName_=`_flags_removeExclamationName ${flags_name_}` - flags_usName_=`_flags_underscoreName ${flags_usName_}` - flags_strToEval_="unset FLAGS_${flags_usName_}" - for flags_type_ in \ - ${__FLAGS_INFO_DEFAULT} \ - ${__FLAGS_INFO_HELP} \ - ${__FLAGS_INFO_SHORT} \ - ${__FLAGS_INFO_TYPE} - do - flags_strToEval_=\ + flags_usName_=`_flags_removeExclamationName ${flags_name_}` + flags_usName_=`_flags_underscoreName ${flags_usName_}` + flags_strToEval_="unset FLAGS_${flags_usName_}" + for flags_type_ in \ + ${__FLAGS_INFO_DEFAULT} \ + ${__FLAGS_INFO_HELP} \ + ${__FLAGS_INFO_SHORT} \ + ${__FLAGS_INFO_TYPE} + do + flags_strToEval_=\ "${flags_strToEval_} __flags_${flags_usName_}_${flags_type_}" - done - eval ${flags_strToEval_} + done + eval ${flags_strToEval_} done # reset internal variables From 5b87733f7e756103d52b8434d61b0bc895505a3b Mon Sep 17 00:00:00 2001 From: Peter van der Does Date: Mon, 25 Jul 2016 20:20:41 -0400 Subject: [PATCH 32/39] Add option set set allow multi-hotfix through simple cli. --- git-flow-config | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/git-flow-config b/git-flow-config index 9850ebd2..e9d54570 100644 --- a/git-flow-config +++ b/git-flow-config @@ -137,8 +137,6 @@ git flow config set