#!/bin/sh # # git-flow -- A collection of Git extensions to provide high-level # repository operations for Vincent Driessen's branching model. # # A blog post presenting this model is found at: # http://blog.avirtualhome.com/development-workflow-using-git/ # # Feel free to contribute to this project at: # http://github.com/petervanderdoes/gitflow # # Authors: # Copyright 2012,2013 Peter van der Does. All rights reserved. # # 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: # # 1. Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # enable debug mode if [ "$DEBUG" = "yes" ]; then set -x fi + '[' '' = yes ']' # Setup the GITFLOW_DIR for different operating systems. # This is mostly to make sure that we get the correct directory when the # git-flow file is a symbolic link case $(uname -s) in Linux) export GITFLOW_DIR=$(dirname "$(readlink -e "$0")") ;; FreeBSD|OpenBSD|NetBSD) export FLAGS_GETOPT_CMD='/usr/local/bin/getopt' export GITFLOW_DIR=$(dirname "$(realpath "$0")") ;; Darwin) PRG="$0" while [ -h "$PRG" ]; do link=$(readlink "$0") if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG="$(dirname "$PRG")/$link" fi done export GITFLOW_DIR=$(dirname "$PRG") ;; *MINGW*) export GITFLOW_DIR=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") ;; *) # The sed expression here replaces all backslashes by forward slashes. # This helps our Windows users, while not bothering our Unix users.) export GITFLOW_DIR=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") ;; esac + case $(uname -s) in uname -s ++ uname -s + PRG=/opt/local/bin/git-flow + '[' -h /opt/local/bin/git-flow ']' dirname "$PRG" ++ dirname /opt/local/bin/git-flow + export GITFLOW_DIR=/opt/local/bin + GITFLOW_DIR=/opt/local/bin # Extra environment settings if [ -f ~/.gitflow_export ]; then if grep -E 'GITFLOW_FLAG_(SHOWCOMMANDS|INIT|FEATURE|HOTFIX|RELEASE|SUPPORT)' ~/.gitflow_export > /dev/null; then echo "Using environment variables for \"showcommands\", \"init\", \"feature\", \"hotfix\", \"release\" and \"support\" in ~/.gitflow_export has deprecated, use git config instead." echo "" exit 1; else . ~/.gitflow_export fi fi + '[' -f /Users/USERNAME/.gitflow_export ']' usage() { echo "usage: git flow " echo echo "Available subcommands are:" echo " init Initialize a new git repo with support for the branching model." echo " feature Manage your feature branches." echo " release Manage your release branches." echo " hotfix Manage your hotfix branches." echo " support Manage your support branches." echo " version Shows version information." echo " config Manage your git-flow configuration." echo echo "Try 'git flow help' for details." } main() { if [ $# -lt 1 ]; then usage exit 1 fi # Use the shFlags project to parse the command line arguments . "$GITFLOW_DIR/gitflow-shFlags" FLAGS_PARENT="git flow" # Load common functionality . "$GITFLOW_DIR/gitflow-common" # allow user to request git action logging DEFINE_boolean 'showcommands' false 'Show actions taken (git commands)' # but if the user prefers that the logging is always on, # use the environmental variables. gitflow_override_flag_boolean 'showcommands' 'showcommands' # Sanity checks SUBCOMMAND="$1"; shift if [ "${SUBCOMMAND}" = "finish" ] || [ "${SUBCOMMAND}" = "delete" ] || [ "${SUBCOMMAND}" = "publish" ]; then _current_branch=$(git_current_branch) if gitflow_is_prefixed_branch "${_current_branch}"; then if startswith "${_current_branch}" $(git config --get gitflow.prefix.feature); then SUBACTION="${SUBCOMMAND}" SUBCOMMAND="feature" _prefix=$(git config --get gitflow.prefix.feature) _short_branch_name=$(echo ${_current_branch#*${_prefix}}) else if startswith "${_current_branch}" $(git config --get gitflow.prefix.hotfix); then SUBACTION="${SUBCOMMAND}" SUBCOMMAND="hotfix" _prefix=$(git config --get gitflow.prefix.hotfix) _short_branch_name=$(echo ${_current_branch#*${_prefix}}) else if startswith "${_current_branch}" $(git config --get gitflow.prefix.release); then SUBACTION="${SUBCOMMAND}" SUBCOMMAND="release" _prefix=$(git config --get gitflow.prefix.release) _short_branch_name=$(echo ${_current_branch#*${_prefix}}) fi fi fi fi fi if [ ! -e "$GITFLOW_DIR/git-flow-$SUBCOMMAND" ]; then usage exit 1 fi # Run command . "$GITFLOW_DIR/git-flow-$SUBCOMMAND" FLAGS_PARENT="git flow $SUBCOMMAND" if [ -z "${SUBACTION}" ]; then # If the first argument is a flag, it starts with '-', we interpret this # argument as a flag for the default command. if startswith "$1" "-"; then SUBACTION="default" elif [ -z "$1" ]; then SUBACTION="default" else SUBACTION="$1" shift # Do not allow direct calls to subactions with an underscore. if $(contains "$SUBACTION" "_"); then warn "Unknown subcommand: '$SUBACTION'" usage exit 1 fi # Replace the dash with an underscore as bash doesn't allow a dash # in the function name. SUBACTION=$(echo "$SUBACTION" |tr '-' '_') fi fi if ! type "cmd_$SUBACTION" >/dev/null 2>&1; then warn "Unknown subcommand: '$SUBACTION'" usage exit 1 fi # Run the specified action if [ $SUBACTION != "help" ] && [ $SUBCOMMAND != "init" ]; then initialize fi if [ $SUBACTION != 'default' ]; then FLAGS_PARENT="git flow $SUBCOMMAND $SUBACTION" fi cmd_$SUBACTION "$@" "${_short_branch_name}" } main "$@" + main feature finish f3 + '[' 3 -lt 1 ']' + . /opt/local/bin/gitflow-shFlags # $Id$ # vim:et:ft=sh:sts=2:sw=2 # # Copyright 2008 Kate Ward. All Rights Reserved. # Released under the LGPL (GNU Lesser General Public License) # # shFlags -- Advanced command-line flag library for Unix shell scripts. # http://code.google.com/p/shflags/ # # Author: kate.ward@forestent.com (Kate Ward) # # This module implements something like the google-gflags library available # from http://code.google.com/p/google-gflags/. # # FLAG TYPES: This is a list of the DEFINE_*'s that you can do. All flags take # a name, default value, help-string, and optional 'short' name (one-letter # name). Some flags have other arguments, which are described with the flag. # # DEFINE_string: takes any input, and intreprets it as a string. # # DEFINE_boolean: does not take any arguments. Say --myflag to set # FLAGS_myflag to true, or --nomyflag to set FLAGS_myflag to false. For short # flags, passing the flag on the command-line negates the default value, i.e. # if the default is true, passing the flag sets the value to false. # # DEFINE_float: takes an input and intreprets it as a floating point number. As # shell does not support floats per-se, the input is merely validated as # being a valid floating point value. # # DEFINE_integer: takes an input and intreprets it as an integer. # # SPECIAL FLAGS: There are a few flags that have special meaning: # --help (or -?) prints a list of all the flags in a human-readable fashion # --flagfile=foo read flags from foo. (not implemented yet) # -- as in getopt(), terminates flag-processing # # EXAMPLE USAGE: # # -- begin hello.sh -- # #! /bin/sh # . ./shflags # DEFINE_string name 'world' "somebody's name" n # FLAGS "$@" || exit $? # eval set -- "${FLAGS_ARGV}" # echo "Hello, ${FLAGS_name}." # -- end hello.sh -- # # $ ./hello.sh -n Kate # Hello, Kate. # # CUSTOMIZABLE BEHAVIOR: # # A script can override the default 'getopt' command by providing the path to # an alternate implementation by defining the FLAGS_GETOPT_CMD variable. # # NOTES: # # * Not all systems include a getopt version that supports long flags. On these # systems, only short flags are recognized. #============================================================================== # shFlags # # Shared attributes: # flags_error: last error message # flags_output: last function output (rarely valid) # flags_return: last return value # # __flags_longNames: list of long names for all flags # __flags_shortNames: list of short names for all flags # __flags_boolNames: list of boolean flag names # # __flags_opts: options parsed by getopt # # Per-flag attributes: # FLAGS_: contains value of flag named 'flag_name' # __flags__default: the default flag value # __flags__help: the flag help string # __flags__short: the flag short name # __flags__type: the flag type # # Notes: # - lists of strings are space separated, and a null value is the '~' char. # return if FLAGS already loaded [ -n "${FLAGS_VERSION:-}" ] && return 0 ++ '[' -n '' ']' FLAGS_VERSION='1.0.4pre' ++ FLAGS_VERSION=1.0.4pre # return values that scripts can use FLAGS_TRUE=0 ++ FLAGS_TRUE=0 FLAGS_FALSE=1 ++ FLAGS_FALSE=1 FLAGS_ERROR=2 ++ FLAGS_ERROR=2 # determine some reasonable command defaults __FLAGS_UNAME_S=`uname -s` uname -s +++ uname -s ++ __FLAGS_UNAME_S=Darwin case "${__FLAGS_UNAME_S}" in BSD) __FLAGS_EXPR_CMD='gexpr' ;; *) __FLAGS_EXPR_CMD='expr' ;; esac ++ case "${__FLAGS_UNAME_S}" in ++ __FLAGS_EXPR_CMD=expr # commands a user can override if needed FLAGS_EXPR_CMD=${FLAGS_EXPR_CMD:-${__FLAGS_EXPR_CMD}} ++ FLAGS_EXPR_CMD=expr FLAGS_GETOPT_CMD=${FLAGS_GETOPT_CMD:-getopt} ++ FLAGS_GETOPT_CMD=getopt # specific shell checks 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' fi if [ -z "${FLAGS_PARENT:-}" ]; then _flags_fatal "zsh does not pass \$0 through properly. please declare' \ \"FLAGS_PARENT=\$0\" before calling shFlags" fi fi ++ '[' -n '' ']' # can we use built-ins? ( echo "${FLAGS_TRUE#0}"; ) >/dev/null 2>&1 if [ $? -eq ${FLAGS_TRUE} ]; then __FLAGS_USE_BUILTIN=${FLAGS_TRUE} else __FLAGS_USE_BUILTIN=${FLAGS_FALSE} fi ++ '[' 0 -eq 0 ']' ++ __FLAGS_USE_BUILTIN=0 # # constants # # reserved flag names __FLAGS_RESERVED_LIST=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE ' ++ __FLAGS_RESERVED_LIST=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE ' __FLAGS_RESERVED_LIST="${__FLAGS_RESERVED_LIST} VERSION " ++ __FLAGS_RESERVED_LIST=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' # getopt version __FLAGS_GETOPT_VERS_STD=0 ++ __FLAGS_GETOPT_VERS_STD=0 __FLAGS_GETOPT_VERS_ENH=1 ++ __FLAGS_GETOPT_VERS_ENH=1 __FLAGS_GETOPT_VERS_BSD=2 ++ __FLAGS_GETOPT_VERS_BSD=2 ${FLAGS_GETOPT_CMD} >/dev/null 2>&1 ++ getopt 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 ;; *) _flags_fatal 'unable to determine getopt version' ;; esac ++ case $? in ${FLAGS_GETOPT_CMD} --version +++ getopt --version ++ '[' 'getopt (enhanced) 1.1.5' = '-- ' ']' ++ __FLAGS_GETOPT_VERS=1 # getopt optstring lengths __FLAGS_OPTSTR_SHORT=0 ++ __FLAGS_OPTSTR_SHORT=0 __FLAGS_OPTSTR_LONG=1 ++ __FLAGS_OPTSTR_LONG=1 __FLAGS_NULL='~' ++ __FLAGS_NULL='~' # flag info strings __FLAGS_INFO_DEFAULT='default' ++ __FLAGS_INFO_DEFAULT=default __FLAGS_INFO_HELP='help' ++ __FLAGS_INFO_HELP=help __FLAGS_INFO_SHORT='short' ++ __FLAGS_INFO_SHORT=short __FLAGS_INFO_TYPE='type' ++ __FLAGS_INFO_TYPE=type # flag lengths __FLAGS_LEN_SHORT=0 ++ __FLAGS_LEN_SHORT=0 __FLAGS_LEN_LONG=1 ++ __FLAGS_LEN_LONG=1 # flag types __FLAGS_TYPE_NONE=0 ++ __FLAGS_TYPE_NONE=0 __FLAGS_TYPE_BOOLEAN=1 ++ __FLAGS_TYPE_BOOLEAN=1 __FLAGS_TYPE_FLOAT=2 ++ __FLAGS_TYPE_FLOAT=2 __FLAGS_TYPE_INTEGER=3 ++ __FLAGS_TYPE_INTEGER=3 __FLAGS_TYPE_STRING=4 ++ __FLAGS_TYPE_STRING=4 # set the constants readonly __flags_constants=`set |awk -F= '/^FLAGS_/ || /^__FLAGS_/ {print $1}'` set |awk -F= '/^FLAGS_/ || /^__FLAGS_/ {print $1}' +++ set +++ awk -F= '/^FLAGS_/ || /^__FLAGS_/ {print $1}' ++ __flags_constants='FLAGS_ERROR FLAGS_EXPR_CMD FLAGS_FALSE FLAGS_GETOPT_CMD FLAGS_TRUE FLAGS_VERSION __FLAGS_EXPR_CMD __FLAGS_GETOPT_VERS __FLAGS_GETOPT_VERS_BSD __FLAGS_GETOPT_VERS_ENH __FLAGS_GETOPT_VERS_STD __FLAGS_INFO_DEFAULT __FLAGS_INFO_HELP __FLAGS_INFO_SHORT __FLAGS_INFO_TYPE __FLAGS_LEN_LONG __FLAGS_LEN_SHORT __FLAGS_NULL __FLAGS_OPTSTR_LONG __FLAGS_OPTSTR_SHORT __FLAGS_RESERVED_LIST __FLAGS_TYPE_BOOLEAN __FLAGS_TYPE_FLOAT __FLAGS_TYPE_INTEGER __FLAGS_TYPE_NONE __FLAGS_TYPE_STRING __FLAGS_UNAME_S __FLAGS_USE_BUILTIN' for __flags_const in ${__flags_constants}; do # skip certain flags case ${__flags_const} in FLAGS_HELP) continue ;; FLAGS_PARENT) continue ;; esac # set flag readonly if [ -z "${ZSH_VERSION:-}" ]; then readonly ${__flags_const} else # handle zsh case ${ZSH_VERSION} in [123].*) readonly ${__flags_const} ;; *) readonly -g ${__flags_const} ;; # declare readonly constants globally esac fi done ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly FLAGS_ERROR ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly FLAGS_EXPR_CMD ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly FLAGS_FALSE ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly FLAGS_GETOPT_CMD ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly FLAGS_TRUE ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly FLAGS_VERSION ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_EXPR_CMD ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_GETOPT_VERS ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_GETOPT_VERS_BSD ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_GETOPT_VERS_ENH ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_GETOPT_VERS_STD ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_INFO_DEFAULT ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_INFO_HELP ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_INFO_SHORT ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_INFO_TYPE ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_LEN_LONG ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_LEN_SHORT ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_NULL ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_OPTSTR_LONG ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_OPTSTR_SHORT ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_RESERVED_LIST ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_TYPE_BOOLEAN ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_TYPE_FLOAT ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_TYPE_INTEGER ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_TYPE_NONE ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_TYPE_STRING ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_UNAME_S ++ for __flags_const in '${__flags_constants}' ++ case ${__flags_const} in ++ '[' -z '' ']' ++ readonly __FLAGS_USE_BUILTIN unset __flags_const __flags_constants ++ unset __flags_const __flags_constants # # internal variables # # space separated lists __flags_boolNames=' ' # boolean flag names ++ __flags_boolNames=' ' __flags_longNames=' ' # long flag names ++ __flags_longNames=' ' __flags_shortNames=' ' # short flag names ++ __flags_shortNames=' ' __flags_definedNames=' ' # defined flag names (used for validation) ++ __flags_definedNames=' ' __flags_nonegateNames=' ' ++ __flags_nonegateNames=' ' __flags_columns='' # screen width in columns ++ __flags_columns= __flags_opts='' # temporary storage for parsed getopt flags ++ __flags_opts= #------------------------------------------------------------------------------ # private functions # # logging functions _flags_debug() { echo "flags:DEBUG $@" >&2; } _flags_warn() { echo "flags:WARN $@" >&2; } _flags_error() { echo "flags:ERROR $@" >&2; } _flags_fatal() { echo "flags:FATAL $@" >&2; exit ${FLAGS_ERROR}; } # Define a flag. # # Calling this function will define the following info variables for the # specified flag: # FLAGS_flagname - the name for this flag (based upon the long flag name) # __flags__default - the default value # __flags_flagname_help - the help string # __flags_flagname_short - the single letter alias # __flags_flagname_type - the type of flag (one of __FLAGS_TYPE_*) # # Args: # _flags__type: integer: internal type of flag (__FLAGS_TYPE_*) # _flags__name: string: long flag name # _flags__default: default flag value # _flags__help: string: help string # _flags__short: string: (optional) short flag name # Returns: # integer: success of operation, or 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} fi _flags_type_=$1 _flags_name_=$2 _flags_default_=$3 _flags_help_=$4 _flags_short_=${5:-${__FLAGS_NULL}} _flags_return_=${FLAGS_TRUE} _flags_usName_=`_flags_removeExclamationName ${_flags_name_}` _flags_usName_=`_flags_underscoreName ${_flags_usName_}` # 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} 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}" ] then 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 fi # check for existing short name definition if [ ${_flags_return_} -eq ${FLAGS_TRUE} \ -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 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 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}=\ \"${_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 fi flags_return=${_flags_return_} unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ \ _flags_short_ _flags_type_ _flags_usName_ [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_error "${flags_error}" return ${flags_return} } # Underscore a flag name by replacing dashes with underscores. # # Args: # unnamed: string: log flag name # Output: # string: underscored name _flags_underscoreName() { echo $1 |tr '-' '_' } # Strip potential exclamation mark # # Args: # unnamed: string: log flag name # Output: # string: exclamation stripped from name _flags_removeExclamationName() { _flags_opt_=$1 if _flags_isNegate "${_flags_opt_}"; then echo ${_flags_opt_} else if _flags_useBuiltin; then echo ${_flags_opt_%!*} else echo ${_flags_opt_}|sed 's/!$//' fi fi unset _flags_opt_ return ${FLAGS_TRUE} } # Check if a flag ends in an exclamation mark, # if it does, there will not be a negate option # Args: # unnamed: string: flag name # return: # boolean _flags_isNegate() { case $1 in *!) flags_return=${FLAGS_FALSE} ;; *) flags_return=${FLAGS_TRUE} ;; esac return ${flags_return} } # Return valid getopt options using currently defined list of long options. # # This function builds a proper getopt option string for short (and long) # options, using the current list of long options for reference. # # Args: # _flags_optStr: integer: option string type (__FLAGS_OPTSTR_*) # Output: # string: generated option string for getopt # Returns: # boolean: success of operation (always returns True) _flags_genOptStr() { _flags_optStrType_=$1 _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 done echo "${_flags_opts_}" unset _flags_name_ _flags_opts_ _flags_optStrType_ _flags_shortName_ \ _flags_type_ _flags_usName_ return ${FLAGS_TRUE} } # Returns flag details based on a flag name and flag info. # # Args: # string: underscored flag name # string: flag info (see the _flags_define function for valid info types) # Output: # string: value of dereferenced flag variable # Returns: # integer: one of FLAGS_{TRUE|FALSE|ERROR} _flags_getFlagInfo() { # note: adding gFI to variable names to prevent naming conflicts with calling # functions _flags_gFI_usName_=$1 _flags_gFI_info_=$2 _flags_infoVar_="__flags_${_flags_gFI_usName_}_${_flags_gFI_info_}" _flags_strToEval_="_flags_infoValue_=\"\${${_flags_infoVar_}:-}\"" eval "${_flags_strToEval_}" if [ -n "${_flags_infoValue_}" ]; then 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 fi echo "${_flags_infoValue_}" unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ \ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_error "${flags_error}" return ${flags_return} } # Check for presense of item in a list. # # Passed a string (e.g. 'abc'), this function will determine if the string is # present in the list of strings (e.g. ' foo bar abc '). # # Args: # _flags_str_: string: string to search for in a list of strings # unnamed: list: list of strings # Returns: # boolean: true if item is in the list _flags_itemInList() { _flags_str_=$1 shift _flags_list_=" ${*:-} " case ${_flags_list_} in *\ ${_flags_str_}\ *) flags_return=$FLAGS_TRUE ;; *) flags_return=$FLAGS_FALSE ;; esac unset _flags_str_ _flags_list_ return ${flags_return} } # Returns the width of the current screen. # # Output: # integer: width in columns of the current screen. _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 fi echo ${__flags_columns} } # Validate a boolean. # # Args: # _flags__bool: boolean: value to validate # Returns: # bool: true if the value is a valid boolean _flags_validBool() { _flags_bool_=$1 flags_return=${FLAGS_TRUE} case "${_flags_bool_}" in true|t|0) ;; false|f|1) ;; *) flags_return=${FLAGS_FALSE} ;; esac unset _flags_bool_ return ${flags_return} } # Validate a float. # # Args: # _flags_float_: float: value to validate # Returns: # bool: true if the value is a valid integer _flags_validFloat() { flags_return=${FLAGS_FALSE} [ -n "$1" ] || return ${flags_return} _flags_float_=$1 if _flags_validInt ${_flags_float_}; then 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_ 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_ fi unset _flags_float_ _flags_float_whole_ _flags_float_fraction_ return ${flags_return} } # Validate an integer. # # Args: # _flags_int_: integer: value to validate # Returns: # bool: true if the value is a valid integer _flags_validInt() { flags_return=${FLAGS_FALSE} [ -n "$1" ] || return ${flags_return} _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 ;; esac case ${_flags_int_} in *[!0-9]*) flags_return=${FLAGS_FALSE} ;; *) flags_return=${FLAGS_TRUE} ;; esac unset _flags_int_ return ${flags_return} } # Parse command-line options using the standard getopt. # # Note: the flag options are passed around in the global __flags_opts so that # the formatting is not lost due to shell parsing and such. # # Args: # @: varies: command-line options to parse # Returns: # integer: a FLAGS success condition _flags_getoptStandard() { flags_return=${FLAGS_TRUE} _flags_shortOpts_=`_flags_genOptStr ${__FLAGS_OPTSTR_SHORT}` # 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 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 fi unset _flags_match_ _flags_opt_ _flags_rtrn_ _flags_shortOpts_ return ${flags_return} } # Parse command-line options using the enhanced getopt. # # Note: the flag options are passed around in the global __flags_opts so that # the formatting is not lost due to shell parsing and such. # # Args: # @: varies: command-line options to parse # Returns: # integer: a FLAGS success condition _flags_getoptEnhanced() { flags_return=${FLAGS_TRUE} _flags_shortOpts_=`_flags_genOptStr ${__FLAGS_OPTSTR_SHORT}` _flags_boolOpts_=`echo "${__flags_boolNames}" \ |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` _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 unset _flags_boolOpts_ _flags_longOpts_ _flags_rtrn_ _flags_shortOpts_ return ${flags_return} } # Dynamically parse a getopt result and set appropriate variables. # # This function does the actual conversion of getopt output and runs it through # the standard case structure for parsing. The case structure is actually quite # dynamic to support any number of flags. # # Args: # argc: int: original command-line argument count # @: varies: output from getopt parsing # Returns: # integer: a FLAGS success condition _flags_parseGetopt() { _flags_argc_=$1 shift flags_return=${FLAGS_TRUE} if [ ${__FLAGS_GETOPT_VERS} -ne ${__FLAGS_GETOPT_VERS_ENH} ]; then set -- $@ else # note the quotes around the `$@' -- they are essential! eval set -- "$@" fi # Provide user with the number of arguments to shift by later. # NOTE: the FLAGS_ARGC variable is obsolete as of 1.0.3 because it does not # properly give user access to non-flag arguments mixed in between flag # arguments. Its usage was replaced by FLAGS_ARGV, and it is being kept only # for backwards compatibility reasons. FLAGS_ARGC=`_flags_math "$# - 1 - ${_flags_argc_}"` # 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_${_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 done # give user back non-flag arguments FLAGS_ARGV='' while [ $# -gt 0 ]; do 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_ return ${flags_return} } # Perform some path using built-ins. # # Args: # $@: string: math expression to evaluate # Output: # integer: the result # Returns: # bool: success of math evaluation _flags_math() { if [ $# -eq 0 ]; then 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_ else eval expr $@ flags_return=$? fi return ${flags_return} } # Cross-platform strlen() implementation. # # Args: # _flags_str: string: to determine length of # Output: # integer: length of string # Returns: # bool: success of strlen evaluation _flags_strlen() { _flags_str_=${1:-} if [ -z "${_flags_str_}" ]; then flags_output=0 elif _flags_useBuiltin; then flags_output=${#_flags_str_} else flags_output=`${FLAGS_EXPR_CMD} -- "${_flags_str_}" : '.*'` fi flags_return=$? unset _flags_str_ echo ${flags_output} return ${flags_return} } # Use built-in helper function to enable unit testing. # # Args: # None # Returns: # bool: true if built-ins should be used _flags_useBuiltin() { return ${__FLAGS_USE_BUILTIN} } #------------------------------------------------------------------------------ # public functions # # A basic boolean flag. Boolean flags do not take any arguments, and their # value is either 1 (false) or 0 (true). For long flags, the false value is # specified on the command line by prepending the word 'no'. With short flags, # the presense of the flag toggles the current value between true and false. # Specifying a short boolean flag twice on the command results in returning the # value back to the default value. # # A default value is required for boolean flags. # # For example, lets say a Boolean flag was created whose long name was 'update' # and whose short name was 'x', and the default value was 'false'. This flag # could be explicitly set to 'true' with '--update' or by '-x', and it could be # explicitly set to 'false' with '--noupdate'. DEFINE_boolean() { _flags_define ${__FLAGS_TYPE_BOOLEAN} "$@"; } # Other basic flags. DEFINE_float() { _flags_define ${__FLAGS_TYPE_FLOAT} "$@"; } DEFINE_integer() { _flags_define ${__FLAGS_TYPE_INTEGER} "$@"; } DEFINE_string() { _flags_define ${__FLAGS_TYPE_STRING} "$@"; } # Parse the flags. # # Args: # unnamed: list: command-line flags to parse # Returns: # integer: success of operation, or error FLAGS() { # define a standard 'help' flag if one isn't already defined [ -z "${__flags_help_type:-}" ] && \ 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=$? else # 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=$? fi [ ${flags_return} -eq ${FLAGS_ERROR} ] && _flags_fatal "${flags_error}" return ${flags_return} } # This is a helper function for determining the 'getopt' version for platforms # where the detection isn't working. It simply outputs debug information that # can be included in a bug report. # # Args: # none # Output: # debug info that can be included in a bug report # Returns: # nothing flags_getoptInfo() { # platform info _flags_debug "uname -a: `uname -a`" _flags_debug "PATH: ${PATH}" # shell info if [ -n "${BASH_VERSION:-}" ]; then _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}" fi # getopt info ${FLAGS_GETOPT_CMD} >/dev/null _flags_getoptReturn=$? _flags_debug "getopt return: ${_flags_getoptReturn}" _flags_debug "getopt --version: `${FLAGS_GETOPT_CMD} --version 2>&1`" unset _flags_getoptReturn } # Returns whether the detected getopt version is the enhanced version. # # Args: # none # Output: # none # Returns: # bool: true if getopt is the enhanced version flags_getoptIsEnh() { test ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_ENH} } # Returns whether the detected getopt version is the standard version. # # Args: # none # Returns: # bool: true if getopt is the standard version flags_getoptIsStd() { test ${__FLAGS_GETOPT_VERS} -eq ${__FLAGS_GETOPT_VERS_STD} } # This is effectively a 'usage()' function. It prints usage information and # exits the program with ${FLAGS_FALSE} if it is ever found in the command line # arguments. Note this function can be overridden so other apps can define # their own --help flag, replacing this one, if they want. # # Args: # none # Returns: # integer: success of operation (always returns true) flags_help() { if [ -n "${FLAGS_HELP:-}" ]; then echo "${FLAGS_HELP}" >&2 else 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 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_ return ${FLAGS_TRUE} } # Reset shflags back to an uninitialized state. # # Args: # none # Returns: # nothing 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_strToEval_} __flags_${flags_usName_}_${flags_type_}" done eval ${flags_strToEval_} done # reset internal variables __flags_boolNames=' ' __flags_longNames=' ' __flags_shortNames=' ' __flags_definedNames=' ' unset flags_name_ flags_type_ flags_strToEval_ flags_usName_ } + FLAGS_PARENT='git flow' + . /opt/local/bin/gitflow-common # # git-flow -- A collection of Git extensions to provide high-level # repository operations for Vincent Driessen's branching model. # # A blog post presenting this model is found at: # http://blog.avirtualhome.com/development-workflow-using-git/ # # Feel free to contribute to this project at: # http://github.com/petervanderdoes/gitflow # # Authors: # Copyright 2012,2013 Peter van der Does. All rights reserved. # # 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: # # 1. Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # # Common functionality # # Shell output warn() { echo "$@" >&2; } die() { warn "Fatal: $@"; exit 1; } die_help() { warn $@; flags_help; exit 1; } escape() { echo "$1" | sed 's/\([\.\$\*]\)/\\\1/g' } # # String contains function # $1 haystack # $2 Needle # contains() { local return case $1 in *$2*) return=$FLAGS_TRUE ;; *) return=$FLAGS_FALSE ;; esac return $return } # Basic math min() { [ "$1" -le "$2" ] && echo "$1" || echo "$2"; } max() { [ "$1" -ge "$2" ] && echo "$1" || echo "$2"; } # Basic string matching startswith() { [ "$1" != "${1#$2}" ]; } endswith() { [ "$1" != "${1%$2}" ]; } # Convenience functions for checking shFlags flags flag() { local FLAG; eval FLAG='$FLAGS_'$1; [ $FLAG -eq $FLAGS_TRUE ]; } noflag() { local FLAG; eval FLAG='$FLAGS_'$1; [ $FLAG -ne $FLAGS_TRUE ]; } # check_boolean # Check if given value can be interpreted as a boolean # # This function determines if the passed parameter is a valid boolean value. # # Param $1: string Value to check if it's a valid boolean # # Return: string FLAGS_TRUE|FLAGS_FALSE|FLAGS_ERROR # FLAGS_TRUE if the parameter is a boolean TRUE # FLAGS_FALSE if the parameter is a boolean FALSE # FLAGS_ERROR if the parameter is not a boolean # check_boolean() { local _return _value _value="${1}" case "${_value}" in ${FLAGS_TRUE} | [yY] | [yY][eE][sS] | [tT] | [tT][rR][uU][eE]) _return=${FLAGS_TRUE} ;; ${FLAGS_FALSE} | [nN] | [nN][oO] | [fF] | [fF][aA][lL][sS][eE]) _return=${FLAGS_FALSE} ;; *) _return=${FLAGS_ERROR} ;; esac unset _value return ${_return} } # # Git specific common functionality # git_local_branches() { git for-each-ref --format='%(refname:short)' refs/heads; } git_remote_branches() { git for-each-ref --format='%(refname:short)' refs/remotes; } git_all_branches() { git for-each-ref --format='%(refname:short)' refs/remotes refs/heads; } git_all_tags() { git for-each-ref --format='%(refname:short)' refs/tags; } git_local_branches_prefixed() { [ -z $1 ] && die "Prefix parameter missing." # This should never happen. git for-each-ref --format='%(refname:short)' refs/heads/$1 ; } git_current_branch() { local branch_name branch_name="$(git symbolic-ref --quiet HEAD)" [ -z $branch_name ] && branch_name="(unnamed branch)" || branch_name="$(git for-each-ref --format='%(refname:short)' $branch_name)" echo "$branch_name" } git_is_clean_working_tree() { git rev-parse --verify HEAD >/dev/null || exit 1 git update-index -q --ignore-submodules --refresh # Check for unstaged changes git diff-files --quiet --ignore-submodules || return 1 # Check for Uncommited changes git diff-index --cached --quiet --ignore-submodules HEAD -- || return 2 return 0 } git_repo_is_headless() { ! git rev-parse --quiet --verify HEAD >/dev/null 2>&1 } git_local_branch_exists() { [ -n "$1" ] || die "Missing branch name" [ -n "$(git for-each-ref --format='%(refname:short)' refs/heads/$1)" ] } git_remote_branch_exists() { [ -n "$1" ] || die "Missing branch name" [ -n "$(git for-each-ref --format='%(refname:short)' refs/remotes/$1)" ] } git_remote_branch_delete() { [ -n "$1" ] || die "Missing branch name" if git_remote_branch_exists "$ORIGIN/$1"; then git_do push "$ORIGIN" :"$1" || die "Could not delete the remote $1 in $ORIGIN." else warn "Trying to delete the remote branch $1, but it does not exists in $ORIGIN" fi } git_branch_exists() { [ -n "$1" ] || die "Missing branch name" git_local_branch_exists "$1" || git_remote_branch_exists "$ORIGIN/$1" } git_tag_exists() { [ -n "$1" ] || die "Missing tag name" [ -n "$(git for-each-ref --format='%(refname:short)' refs/tags/$1)" ] } # # git_compare_refs() # # Tests whether two references have diverged and need merging # first. It returns error codes to provide more detail, like so: # # 0 References point to the same commit # 1 First given reference needs fast-forwarding # 2 Second given reference needs fast-forwarding # 3 References need a real merge # 4 There is no merge base, i.e. the references have no common ancestors # git_compare_refs() { local commit1 commit2 base commit1=$(git rev-parse "$1"^{}) commit2=$(git rev-parse "$2"^{}) if [ "$commit1" != "$commit2" ]; then base=$(git merge-base "$commit1" "$commit2") if [ $? -ne 0 ]; then return 4 elif [ "$commit1" = "$base" ]; then return 1 elif [ "$commit2" = "$base" ]; then return 2 else return 3 fi else return 0 fi } # # git_is_branch_merged_into() # # Checks whether branch $1 is successfully merged into $2 # git_is_branch_merged_into() { local merge_hash base_hash merge_hash=$(git merge-base "$1"^{} "$2"^{}) base_hash=$(git rev-parse "$1"^{}) # If the hashes are equal, the branches are merged. [ "$merge_hash" = "$base_hash" ] } # # git_is_ancestor() # # This is the same function as git_is_branch_merged_into but # for readability given a different name. # git_is_ancestor() { git_is_branch_merged_into "$1" "$2" } # # git_fetch_branch() # # $1 Origin - Where to fetch from # $2 Branch - Which branch to fetch # # This fetches the given branch from the given origin. # Instead of storing it in FETCH_HEAD it will be stored in # refs/remotes// # git_fetch_branch() { local origin branch [ -n "$1" ] || die "Missing origin" [ -n "$2" ] || die "Missing branch name" origin="$1" branch="$2" git_do fetch -q "$origin" "$branch":refs/remotes/"$origin"/"$branch" || die "Could not fetch $branch from $origin." } # # gitflow specific common functionality # # Function used to check if the repository is git-flow enabled. gitflow_has_master_configured() { local master master=$(git config --get gitflow.branch.master) [ "$master" != "" ] && git_local_branch_exists "$master" } gitflow_has_develop_configured() { local develop develop=$(git config --get gitflow.branch.develop) [ "$develop" != "" ] && git_local_branch_exists "$develop" } gitflow_has_prefixes_configured() { git config --get gitflow.prefix.feature >/dev/null 2>&1 && \ git config --get gitflow.prefix.release >/dev/null 2>&1 && \ git config --get gitflow.prefix.hotfix >/dev/null 2>&1 && \ git config --get gitflow.prefix.support >/dev/null 2>&1 && \ git config --get gitflow.prefix.versiontag >/dev/null 2>&1 } gitflow_is_initialized() { gitflow_has_master_configured && \ gitflow_has_develop_configured && \ [ "$(git config --get gitflow.branch.master)" != "$(git config --get gitflow.branch.develop)" ] && \ gitflow_has_prefixes_configured } # Loading settings that can be overridden using git config gitflow_load_settings() { export GIT_CURRENT_REPO_DIR=$(git rev-parse --show-toplevel 2>/dev/null) export DOT_GIT_DIR=$(git rev-parse --git-dir 2>/dev/null) export HOOKS_DIR=$(git config --get gitflow.path.hooks || echo "$DOT_GIT_DIR"/hooks) # the second option is used to support previous versions of git-flow export MASTER_BRANCH=$(git config --get gitflow.branch.master) export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop) export ORIGIN=$(git config --get gitflow.origin || echo origin) GITFLOW_CONFIG=$DOT_GIT_DIR/gitflow_config if [ -f "$GITFLOW_CONFIG" ]; then # move all settings from old .git/gitflow_config to the local conf. warn "Migrating old \"$GITFLOW_CONFIG\" to the \"--local\" repo config." _config_lines=`git config --list --file="$GITFLOW_CONFIG"`; for _config_line in ${_config_lines}; do _key=${_config_line%=*} _value=${_config_line#=*} git_do config --local gitflow.${_key} ${_value} done; mv "$GITFLOW_CONFIG" "$GITFLOW_CONFIG".backup 2>/dev/null fi } # # gitflow_resolve_nameprefix # # Inputs: # $1 = name prefix to resolve # $2 = branch prefix to use # # Searches branch names from git_local_branches() to look for a unique # branch name whose name starts with the given name prefix. # # There are multiple exit codes possible: # 0: The unambiguous full name of the branch is written to stdout # (success) # 1: No match is found. # 2: Multiple matches found. These matches are written to stderr # gitflow_resolve_nameprefix() { local name prefix local match matches num_matches name=$1 prefix=$2 # first, check if there is a perfect match if git_local_branch_exists "$prefix$name"; then echo "$name" return 0 fi matches=$(echo "$(git_local_branches)" | grep "^$(escape "$prefix$name")") num_matches=$(echo "$matches" | wc -l) if [ -z "$matches" ]; then # no prefix match, so take it literally warn "No branch matches prefix '$name'" return 1 else if [ $num_matches -eq 1 ]; then echo "${matches#$prefix}" return 0 else # multiple matches, cannot decide warn "Multiple branches match prefix '$name':" for match in $matches; do warn "- $match" done return 2 fi fi } # # Check if the given branch is a git-flow branch # gitflow_is_prefixed_branch() { local branch return branch=$1 case $branch in $(git config --get gitflow.prefix.feature)* | \ $(git config --get gitflow.prefix.release)* | \ $(git config --get gitflow.prefix.hotfix)* | \ $(git config --get gitflow.prefix.support)* ) return=0 ;; *) return=1 ;; esac return $return } # # Update the config with the base of a new git-flow branch. # # @param $1 Base of the new branch # @param $2 Name of the branch # gitflow_config_set_base_branch() { local base branch base=$1 branch=$2 $(git_do config --local "gitflow.branch.$branch.base" $base) } # # Get the base of a branch as set by gitflow_set_branch # # @param $1 Name of the branch # @return string|empty String when a base is found otherwise empty # gitflow_config_get_base_branch() { local branch branch=$1 echo $(git config --local --get "gitflow.branch.$branch.base") } # # Remove the section that contains the base of a branch as set by gitflow_set_branch # # @param $1 Name of the branch # gitflow_config_remove_base_section() { local branch branch=$1 $(git_do config --local --remove-section "gitflow.branch.$branch" 2>/dev/null) } # # Remove the base of the git-flow branch from the. # @param $1 Name of the branch # gitflow_config_remove_base_branch() { local base base=$1 $(git_do config --local --unset "gitflow.branch.$branch.base" 2>/dev/null) } # gitflow_override_flag_boolean() # # Override a boolean flag # # Param $1: string The name of the config variable e.g. "feature.start.fetch" # Param $2: string The flag name # gitflow_override_flag_boolean() { local _variable _variable=$(git config --bool --get gitflow.$1 2>&1) case $? in 0) [ "${_variable}" = "true" ] && eval "FLAGS_${2}=${FLAGS_TRUE}" || eval "FLAGS_${2}=${FLAGS_FALSE}" ;; 128) die "${_variable}" ;; esac unset _variable return ${FLAGS_TRUE} } # gitflow_override_flag_string() # # Override a string flag # # Param $1: string The name of the config variable e.g. "feature.start.fetch" # Param $2: string The flag name # gitflow_override_flag_string() { local _variable _variable=$(git config --get gitflow.$1 2>&1) case $? in 0) eval "FLAGS_${2}=\"${_variable}\"" ;; esac unset _variable return ${FLAGS_TRUE} } # gitflow_create_squash_message() # # Create the squash message, overriding the one generated by git itself # # Param $1: string The line to be added # Param $2: string The base of the branch that will me merged # Param $3: string The branch that will be merged. # gitflow_create_squash_message() { echo Squashed commit of the following: echo echo $1 echo git log --no-merges --pretty=medium ^"$2" $3 } # # Parameter functions # gitflow_expand_nameprefix_arg_or_current() { if [ "$NAME" != "" ]; then gitflow_expand_nameprefix_arg require_branch "$PREFIX$NAME" else gitflow_use_current_branch_name fi } gitflow_expand_nameprefix_arg() { local expanded_name exitcode gitflow_require_name_arg expanded_name=$(gitflow_resolve_nameprefix "$NAME" "$PREFIX") exitcode=$? case $exitcode in 0) NAME=$expanded_name BRANCH=$PREFIX$NAME ;; *) exit 1 ;; esac } gitflow_require_version_arg() { if [ "$VERSION" = "" ]; then die_help "Missing argument " fi } gitflow_require_name_arg() { if [ "$NAME" = "" ]; then die_help "Missing argument " fi } gitflow_require_base_arg() { if [ "$BASE" = "" ]; then die_help "Missing argument " fi } gitflow_use_current_branch_name() { local current_branch current_branch=$(git_current_branch) if startswith "$current_branch" "$PREFIX"; then BRANCH=$current_branch NAME=${BRANCH#$PREFIX} else warn "The current HEAD is no feature branch." warn "Please specify a argument." exit 1 fi } # # Assertions for use in git-flow subcommands # require_git_repo() { git rev-parse 2>/dev/null || die "Not a git repository" } require_gitflow_initialized() { gitflow_is_initialized || die "Not a gitflow-enabled repo yet. Please run 'git flow init' first." } require_clean_working_tree() { local result git_is_clean_working_tree result=$? if [ $result -eq 1 ]; then die "Working tree contains unstaged changes. Aborting." fi if [ $result -eq 2 ]; then die "Index contains uncommited changes. Aborting." fi } require_base_is_local_branch() { git_local_branch_exists "$1" || die "Base '$1' needs to be a branch. It does not exist and is required." } require_local_branch() { git_local_branch_exists "$1" || die "Local branch '$1' does not exist and is required." } require_remote_branch() { git_remote_branch_exists "$1" || die "Remote branch '$1' does not exist and is required." } require_branch() { git_branch_exists "$1" || die "Branch '$1' does not exist and is required." } require_branch_absent() { git_branch_exists "$1" && die "Branch '$1' already exists. Pick another name." } require_local_branch_absent() { git_local_branch_exists "$1" && die "Branch '$1' already exists. Pick another name." } require_tag_absent() { git_tag_exists "$1" && die "Tag '$1' already exists. Pick another name." } require_branches_equal() { local compare_refs_result require_local_branch "$1" require_remote_branch "$2" git_compare_refs "$1" "$2" compare_refs_result=$? if [ $compare_refs_result -gt 0 ]; then warn "Branches '$1' and '$2' have diverged." if [ $compare_refs_result -eq 1 ]; then die "And branch '$1' may be fast-forwarded." 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 } # # Show commands if flag is set. # git_do() { if flag showcommands; then echo "git $@" >&2 fi git "$@" } # # run_filter_hook # # Looks for a Git hook script called as defined by the first variable # # filter-flow-command # # If such a hook script exists and is executable, it is called with the given # positional arguments. # run_filter_hook() { local command scriptfile return command=$1 shift scriptfile="${HOOKS_DIR}/filter-flow-${command}" if [ -x $scriptfile ]; then return=`$scriptfile "$@"` if [ $? -eq 127 ]; then echo "$return" exit 127 fi echo $return else echo "$@" fi } # # run_pre_hook # # Looks for a Git hook script called # # pre-flow-- # # If such a hook script exists and is executable, it is called with the given # positional arguments. If its return code non-zero, the git-flow action is # aborted. # run_pre_hook() { local scriptfile exitcode scriptfile="${HOOKS_DIR}/pre-flow-${SUBCOMMAND}-${SUBACTION}" exitcode=0 if [ -x $scriptfile ]; then $scriptfile "$@" exitcode=$? if [ $exitcode -gt 0 ]; then die "Hook command $scriptfile ended with exit code $exitcode." fi fi } # # run_post_hook # # Looks for a Git hook script called # # post-flow-- # # If such a hook script exists and is executable, it is called with the given # positional arguments. Its return code is ignored. # run_post_hook() { local scriptfile scriptfile="${HOOKS_DIR}/post-flow-${SUBCOMMAND}-${SUBACTION}" if [ -x $scriptfile ]; then $scriptfile "$@" fi } flags_help() { eval "$( echo "$OPTIONS_SPEC" | git rev-parse --parseopt -- "-h" || echo exit $? )" } + DEFINE_boolean showcommands false 'Show actions taken (git commands)' + _flags_define 1 showcommands false 'Show actions taken (git commands)' + '[' 4 -lt 4 ']' + _flags_type_=1 + _flags_name_=showcommands + _flags_default_=false + _flags_help_='Show actions taken (git commands)' + _flags_short_='~' + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName showcommands ++ _flags_opt_=showcommands ++ _flags_isNegate showcommands ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo showcommands ++ unset _flags_opt_ ++ return 0 + _flags_usName_=showcommands _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName showcommands ++ echo showcommands ++ tr - _ + _flags_usName_=showcommands + _flags_itemInList showcommands ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=showcommands + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a '~' = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList showcommands + _flags_str_=showcommands + shift + _flags_list_=' ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a '~' '!=' '~' ']' + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate showcommands + case $1 in + flags_return=0 + return 0 + _flags_isNegate_=0 + '[' 0 -eq 0 ']' + eval 'FLAGS_showcommands='\''1'\''' FLAGS_showcommands='1' ++ FLAGS_showcommands=1 + eval __flags_showcommands_type=1 __flags_showcommands_type=1 ++ __flags_showcommands_type=1 + eval '__flags_showcommands_default="1"' __flags_showcommands_default="1" ++ __flags_showcommands_default=1 + eval '__flags_showcommands_help="Show actions taken (git commands)"' __flags_showcommands_help="Show actions taken (git commands)" ++ __flags_showcommands_help='Show actions taken (git commands)' + eval '__flags_showcommands_short='\''~'\''' __flags_showcommands_short='~' ++ __flags_showcommands_short='~' + __flags_shortNames=' ~ ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName showcommands ++ _flags_opt_=showcommands ++ _flags_isNegate showcommands ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo showcommands ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands ' + '[' 1 -eq 1 -a 0 -eq 0 ']' + __flags_boolNames=' noshowcommands ' + __flags_definedNames=' showcommands ' + '[' 1 -eq 1 ']' + '[' 0 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands ' + __flags_definedNames=' showcommands noshowcommands showcommands ' + '[' 1 -eq 1 ']' + '[' 0 -eq 1 ']' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + gitflow_override_flag_boolean showcommands showcommands + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.showcommands + _variable= + case $? in + unset _variable + return 0 + SUBCOMMAND=feature + shift + '[' feature = finish ']' + '[' feature = delete ']' + '[' feature = publish ']' + '[' '!' -e /opt/local/bin/git-flow-feature ']' + . /opt/local/bin/git-flow-feature # # git-flow -- A collection of Git extensions to provide high-level # repository operations for Vincent Driessen's branching model. # # A blog post presenting this model is found at: # http://blog.avirtualhome.com/development-workflow-using-git/ # # Feel free to contribute to this project at: # http://github.com/petervanderdoes/gitflow # # Authors: # Copyright 2012,2013 Peter van der Does. All rights reserved. # # 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: # # 1. Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # initialize() { require_git_repo require_gitflow_initialized gitflow_load_settings PREFIX=$(git config --get gitflow.prefix.feature) } usage() { OPTIONS_SPEC="\ git flow feature [list] git flow feature start git flow feature finish git flow feature publish git flow feature track git flow feature diff git flow feature rebase git flow feature checkout git flow feature pull git flow feature delete Manage your feature branches. For more specific help type the command followed by --help -- " flags_help } cmd_default() { cmd_list "$@" } cmd_list() { OPTIONS_SPEC="\ git flow feature [list] [-h] [-v] Lists all the existing feature branches in the local repository. -- h,help! Show this help v,verbose Verbose (more) output " local feature_branches current_branch width branch len local base develop_sha branch_sha # Define flags DEFINE_boolean 'verbose' false 'verbose (more) output' v # Parse argun=ments parse_args "$@" feature_branches=$(git_local_branches_prefixed "$PREFIX") if [ -z "$feature_branches" ]; then warn "No feature branches exist." warn "" warn "You can start a new feature branch:" warn "" warn " git flow feature start []" warn "" exit 0 fi current_branch=$(git_current_branch) # Determine column width first width=0 for branch in $feature_branches; do len=${#branch} width=$(max $width $len) done width=$(($width+3-${#PREFIX})) for branch in $feature_branches; do base=$(git merge-base "$branch" "$DEVELOP_BRANCH") develop_sha=$(git rev-parse "$DEVELOP_BRANCH") branch_sha=$(git rev-parse "$branch") if [ "$branch" = "$current_branch" ]; then printf "* " else printf " " fi if flag verbose; then printf "%-${width}s" "${branch#$PREFIX}" if [ "$branch_sha" = "$develop_sha" ]; then printf "(no commits yet)" elif [ "$base" = "$branch_sha" ]; then printf "(is behind develop, may ff)" elif [ "$base" = "$develop_sha" ]; then printf "(based on latest develop)" else printf "(may be rebased)" fi else printf "%s" "${branch#$PREFIX}" fi echo done } cmd_help() { usage exit 0 } name_or_current() { if [ -z "$NAME" ]; then use_current_feature_branch_name fi } # Parse arguments and set common variables parse_args() { FLAGS "$@" || exit $? eval set -- "${FLAGS_ARGV}" # read arguments into global variables NAME=$1 BRANCH=$PREFIX$NAME } parse_remote_name() { # Parse arguments FLAGS "$@" || exit $? eval set -- "${FLAGS_ARGV}" # read arguments into global variables REMOTE=$1 NAME=$2 BRANCH=$PREFIX$NAME } cmd_start() { OPTIONS_SPEC="\ git flow feature start [-h] [-F] [] Start new feature , optionally basing it on instead of -- h,help! Show this help showcommands! Show git commands while executing them F,[no]fetch Fetch from origin before performing local operation " local base # Define flags DEFINE_boolean 'fetch' false 'fetch from origin before performing local operation' F # Override defaults with values from config gitflow_override_flag_boolean "feature.start.fetch" "fetch" # Parse arguments parse_args "$@" eval set -- "${FLAGS_ARGV}" base=${2:-$DEVELOP_BRANCH} require_base_is_local_branch "$base" gitflow_require_name_arg gitflow_config_set_base_branch $base $BRANCH # Update the local repo with remote changes, if asked if flag fetch; then git_fetch_branch "$ORIGIN" "$base" fi # Sanity checks require_branch_absent "$BRANCH" # If the origin branch counterpart exists, assert that the local branch # isn't behind it (to avoid unnecessary rebasing) if git_remote_branch_exists "$ORIGIN/$base"; then require_branches_equal "$base" "$ORIGIN/$base" fi run_pre_hook "$NAME" "$ORIGIN" "$BRANCH" "$base" # create branch git_do checkout -b "$BRANCH" "$base" || die "Could not create feature branch '$BRANCH'." run_post_hook "$NAME" "$ORIGIN" "$BRANCH" "$base" echo echo "Summary of actions:" echo "- A new branch '$BRANCH' was created, based on '$base'" echo "- You are now on branch '$(git_current_branch)'" echo "" echo "Now, start committing on your feature. When done, use:" echo "" echo " git flow feature finish $NAME" echo } cmd_finish() { OPTIONS_SPEC="\ git flow feature finish [-h] [-F] [-r] [-p] [-k] [-D] [-S] [--no-ff] Finish feature -- h,help! Show this help 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 k,[no]keep Keep branch after performing finish keepremote! Keep the remote branch keeplocal! Keep the local branch D,[no]force_delete Force delete feature branch after finish S,[no]squash Squash feature during merge no-ff! Never fast-forward during the merge " local finish_base # Define flags 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 'keep' false "keep branch after performing finish" k DEFINE_boolean 'keepremote' false "keep the remote branch" DEFINE_boolean 'keeplocal' false "keep the local branch" DEFINE_boolean 'force_delete' false "force delete feature branch after finish" D DEFINE_boolean 'squash' false "squash feature during merge" S DEFINE_boolean 'squash-info' false "add branch info during squash" DEFINE_boolean 'no-ff!' false "Don't fast-forward ever during merge " # Override defaults with values from config 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.keep" "keep" gitflow_override_flag_boolean "feature.finish.keepremote" "keepremote" gitflow_override_flag_boolean "feature.finish.keeplocal" "keeplocal" gitflow_override_flag_boolean "feature.finish.force-delete" "force_delete" gitflow_override_flag_boolean "feature.finish.squash" "squash" gitflow_override_flag_boolean "feature.finish.squash-info" "squash_info" gitflow_override_flag_boolean "feature.finish.no-ff" "no_ff" # Parse arguments parse_args "$@" gitflow_expand_nameprefix_arg_or_current # Keeping both branches implies the --keep flag to be true. if flag keepremote && flag keeplocal; then FLAGS_keep=$FLAGS_TRUE fi # Sanity checks require_branch "$BRANCH" BASE_BRANCH=$(gitflow_config_get_base_branch $BRANCH) BASE_BRANCH=${BASE_BRANCH:-$DEVELOP_BRANCH} git_local_branch_exists "$BASE_BRANCH" || die "The base '$BASE_BRANCH' doesn't exists locally or is not a branch. Can't finish the feature branch '$BRANCH'." # Detect if we're restoring from a merge conflict if [ -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" ]; then # # TODO: detect that we're working on the correct branch here! # The user need not necessarily have given the same $NAME twice here # (although he/she should). # # TODO: git_is_clean_working_tree() should provide an alternative # exit code for "unmerged changes in working tree", which we should # actually be testing for here if git_is_clean_working_tree; then finish_base=$(cat "$DOT_GIT_DIR/.gitflow/MERGE_BASE") # Since the working tree is now clean, either the user did a # successful merge manually, or the merge was cancelled. # We detect this using git_is_branch_merged_into() if git_is_branch_merged_into "$BRANCH" "$finish_base"; then rm -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" helper_finish_cleanup exit 0 else # If the user cancelled the merge and decided to wait until # later,that's fine. But we have to acknowledge this by # removing the MERGE_BASE file and continuing normal execution # of the finish rm -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" fi else echo echo "Merge conflicts not resolved yet, use:" echo " git mergetool" echo " git commit" echo echo "You can then complete the finish by running it again:" echo " git flow feature finish $NAME" echo exit 1 fi fi # Sanity checks require_clean_working_tree # We always fetch the Branch from Origin # This is done to avoid possible commits on the remote that are not # merged into the local branch if git_remote_branch_exists "$ORIGIN/$BRANCH"; then git_fetch_branch "$ORIGIN" "$BRANCH" fi # Update local branches with remote branches if flag fetch; then git_fetch_branch "$ORIGIN" "$BASE_BRANCH" fi # Check if the local branches have all the commits from the remote branches if git_remote_branch_exists "$ORIGIN/$BRANCH"; then require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH" fi if git_remote_branch_exists "$ORIGIN/$BASE_BRANCH"; then require_branches_equal "$BASE_BRANCH" "$ORIGIN/$BASE_BRANCH" fi run_pre_hook "$NAME" "$ORIGIN" "$BRANCH" # If the user wants to rebase, do that first if flag rebase; then local _rebase_opts="" if flag preserve_merges; then _rebase_opts="$_rebase_opts -p" fi if flag showcommands; then _rebase_opts="$_rebase_opts --showcommands" fi if ! git flow feature rebase $_rebase_opts "$NAME"; then warn "Finish was aborted due to conflicts during rebase." warn "Please finish the rebase manually now." warn "When finished, re-run:" warn " git flow feature finish '$NAME' '$BASE_BRANCH'" exit 1 fi fi # Merge into BASE git_do checkout "$BASE_BRANCH" || die "Could not check out branch '$BASE_BRANCH'." if noflag squash; then if flag no_ff; then git_do merge --no-ff "$BRANCH" else if [ "$(git rev-list -n2 "$BASE_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then git_do merge --ff "$BRANCH" else git_do merge --no-ff "$BRANCH" fi fi else git_do merge --squash "$BRANCH" flag squash_info && gitflow_create_squash_message "Merged feature branch '$BRANCH'" "$BASE_BRANCH" "$BRANCH" > "$DOT_GIT_DIR/SQUASH_MSG" git_do commit fi if [ $? -ne 0 ]; then # Oops.. we have a merge conflict! # Write the given $BASE_BRANCH to a temporary file as we will # be needing it later. mkdir -p "$DOT_GIT_DIR/.gitflow" echo "$BASE_BRANCH" > "$DOT_GIT_DIR/.gitflow/MERGE_BASE" echo echo "There were merge conflicts. To resolve the merge conflict manually, use:" echo " git mergetool" echo " git commit" echo echo "You can then complete the finish by running it again:" echo " git flow feature finish $NAME" echo exit 1 fi run_post_hook "$NAME" "$ORIGIN" "$BRANCH" # When no merge conflict is detected, just clean up the feature branch gitflow_config_remove_base_branch "$BRANCH" helper_finish_cleanup } helper_finish_cleanup() { local keepmsg remotebranchdeleted localbranchdeleted # Sanity checks require_branch "$BRANCH" require_clean_working_tree remotebranchdeleted=$FLAGS_FALSE localbranchdeleted=$FLAGS_FALSE if noflag keep; then # Always delete remote first if noflag keepremote;then if git_remote_branch_exists "$ORIGIN/$BRANCH"; then git_remote_branch_delete "$BRANCH" && remotebranchdeleted=$FLAGS_TRUE fi fi # Delete local after remote to avoid warnings if noflag keeplocal; then if [ "$BRANCH" = "$(git_current_branch)" ]; then git_do checkout "$BASE_BRANCH" || die "Could not check out branch '$BASE_BRANCH'." fi if flag force_delete; then git_do branch -D "$BRANCH" && localbranchdeleted=$FLAGS_TRUE else if noflag squash; then git_do branch -d "$BRANCH" && localbranchdeleted=$FLAGS_TRUE else git_do branch -D "$BRANCH" && localbranchdeleted=$FLAGS_TRUE fi fi fi # no more branches: we can safely remove config section if ! git_remote_branch_exists "$ORIGIN/$BRANCH" -a ! git_local_branch_exists "$BRANCH"; then gitflow_config_remove_base_section "$BRANCH" fi fi echo echo "Summary of actions:" echo "- The feature branch '$BRANCH' was merged into '$BASE_BRANCH'" #echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported if noflag keep; then if [ $localbranchdeleted -eq $FLAGS_TRUE ]; then keepmsg="has been locally deleted" else keepmsg="is still locally available" fi if [ $remotebranchdeleted -eq $FLAGS_TRUE ]; then keepmsg=$keepmsg"; it has been remotely deleted from '$ORIGIN'" elif git_remote_branch_exists "$ORIGIN/$BRANCH"; then keepmsg=$keepmsg"; it is still remotely available on '$ORIGIN'" fi else keepmsg="is still locally available" if git_remote_branch_exists "$ORIGIN/$BRANCH"; then keepmsg=$keepmsg"; it is still remotely available on '$ORIGIN'" fi fi echo "- Feature branch '$BRANCH' "$keepmsg echo "- You are now on branch '$(git_current_branch)'" echo } cmd_publish() { OPTIONS_SPEC="\ git flow feature publish [-h] [] Publish feature branch on $ORIGIN. When is omitted the current branch is used, but only if it's a feature branch. -- h,help! Show this help showcommands! Show git commands while executing them " # Parse arguments parse_args "$@" gitflow_expand_nameprefix_arg_or_current # Sanity checks require_clean_working_tree require_branch "$BRANCH" git_do fetch -q "$ORIGIN" || die "Could not fetch branch '$BRANCH' from remote '$ORIGIN'." require_branch_absent "$ORIGIN/$BRANCH" run_pre_hook "$NAME" "$ORIGIN" "$BRANCH" # Create remote branch git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" git_do fetch -q "$ORIGIN" || die "Could not fetch branch '$BRANCH' from remote '$ORIGIN'." # Configure remote tracking git_do config "branch.$BRANCH.remote" "$ORIGIN" git_do config "branch.$BRANCH.merge" "refs/heads/$BRANCH" git_do checkout "$BRANCH" || die "Could not check out branch '$BRANCH'." run_post_hook "$NAME" "$ORIGIN" "$BRANCH" echo echo "Summary of actions:" echo "- A new remote branch '$BRANCH' was created" echo "- The local branch '$BRANCH' was configured to track the remote branch" echo "- You are now on branch '$(git_current_branch)'" echo } cmd_track() { OPTIONS_SPEC="\ git flow feature track [-h] Start tracking feature that is shared on $ORIGIN -- h,help! Show this help showcommands! Show git commands while executing them " # Parse arguments parse_args "$@" gitflow_require_name_arg # Sanity checks require_clean_working_tree require_local_branch_absent "$BRANCH" run_pre_hook "$NAME" "$ORIGIN" "$BRANCH" git_do fetch -q "$ORIGIN" || die "Could not fetch branch '$BRANCH' from remote '$ORIGIN'." git_remote_branch_exists "$ORIGIN/$BRANCH" # Create tracking branch git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH" || die "Could not create '$BRANCH'." run_post_hook "$NAME" "$ORIGIN" "$BRANCH" echo echo "Summary of actions:" echo "- A new remote tracking branch '$BRANCH' was created" echo "- You are now on branch '$(git_current_branch)'" echo } cmd_diff() { OPTIONS_SPEC="\ git flow feature diff [-h] [] Show all changes in that are not in -- h,help! Show this help showcommands! Show git commands while executing them " local base # Parse arguments parse_args "$@" if [ "$NAME" != "" ]; then gitflow_expand_nameprefix_arg base=$(git merge-base "$DEVELOP_BRANCH" "$BRANCH") git_do diff "$base..$BRANCH" else if ! git_current_branch | grep -q "^$PREFIX"; then die "Not on a feature branch. Name one explicitly." fi base=$(git merge-base "$DEVELOP_BRANCH" HEAD) git_do diff "$base" fi } cmd_checkout() { OPTIONS_SPEC="\ git flow feature checkout [-h] [] Switch to feature branch -- h,help! Show this help showcommands! Show git commands while executing them " # Parse arguments parse_args "$@" if [ "$NAME" != "" ]; then gitflow_expand_nameprefix_arg git_do checkout "$BRANCH" || die "Could not check out branch '$BRANCH'." else die "Name a feature branch explicitly." fi } cmd_co() { # Alias for checkout cmd_checkout "$@" } cmd_rebase() { OPTIONS_SPEC="\ git flow feature rebase [-h] [-i] [-p] [] Rebase on -- h,help! Show this help showcommands! Show git commands while executing them i,[no]interactive Do an interactive rebase p,[no]preserve-merges Preserve merges " local opts # Define flags DEFINE_boolean 'interactive' false 'do an interactive rebase' i DEFINE_boolean 'preserve-merges' false 'try to recreate merges' p # Override defaults with values from config gitflow_override_flag_boolean "feature.rebase.interactive" "interactive" gitflow_override_flag_boolean "feature.rebase.preserve-merges" "preserve_merges" # Parse arguments parse_args "$@" gitflow_expand_nameprefix_arg_or_current 'feature' BASE_BRANCH=$(gitflow_config_get_base_branch $BRANCH) BASE_BRANCH=${BASE_BRANCH:-$DEVELOP_BRANCH} warn "Will try to rebase '$NAME' which is based on '$BASE_BRANCH'..." require_clean_working_tree require_branch "$BRANCH" git_local_branch_exists "$BASE_BRANCH" || die "The base '$BASE_BRANCH' doesn't exists locally or is not a branch. Can't finish the feature branch '$BRANCH'." git_do checkout -q "$BRANCH" || die "Could not check out branch '$BRANCH'." if flag interactive; then opts="$opts -i" fi if flag preserve_merges; then opts="$opts -p" fi git_do rebase $opts "$BASE_BRANCH" } avoid_accidental_cross_branch_action() { local current_branch current_branch=$(git_current_branch) if [ "$BRANCH" != "$current_branch" ]; then warn "Trying to pull from '$BRANCH' while currently on branch '$current_branch'." warn "To avoid unintended merges, git-flow aborted." return 1 fi return 0 } cmd_pull() { OPTIONS_SPEC="\ git flow feature pull [-h] [] Pull feature from -- h,help! Show this help showcommands! Show git commands while executing them " local current_branch # Define flags DEFINE_boolean 'rebase' false "pull with rebase" r # Parse arguments parse_remote_name "$@" if [ -z "$REMOTE" ]; then die "Name a remote explicitly." fi name_or_current # To avoid accidentally merging different feature branches into each other, # die if the current feature branch differs from the requested $NAME # argument. current_branch=$(git_current_branch) if startswith "$current_branch" "$PREFIX"; then # We are on a local feature branch already, so $BRANCH must be equal to # the current branch avoid_accidental_cross_branch_action || die fi require_clean_working_tree run_pre_hook "$NAME" "$REMOTE" "$BRANCH" if git_local_branch_exists "$BRANCH"; then # Again, avoid accidental merges avoid_accidental_cross_branch_action || die # We already have a local branch called like this, so simply pull the # remote changes in if flag rebase; then if ! git_do pull --rebase -q "$REMOTE" "$BRANCH"; then warn "Pull was aborted. There might be conflicts during rebase or '$REMOTE' might be inaccessible." exit 1 fi else git_do pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'." fi echo "Pulled $REMOTE's changes into $BRANCH." else # Setup the local branch clone for the first time git_do fetch -q "$REMOTE" "$BRANCH" || die "Could not fetch branch '$BRANCH' from remote '$REMOTE'." # Stores in FETCH_HEAD git_do branch --no-track "$BRANCH" FETCH_HEAD || die "Branch failed." git_do checkout -q "$BRANCH" || die "Could not check out branch '$BRANCH'." echo "Created local branch $BRANCH based on $REMOTE's $BRANCH." fi run_post_hook "$NAME" "$REMOTE" "$BRANCH" } cmd_delete() { OPTIONS_SPEC="\ git flow feature delete [-h] [-f] [-r] Delete a given feature branch -- h,help! Show this help showcommands! Show git commands while executing them f,[no]force Force deletion r,[no]remote Delete remote branch " local current_branch # Define flags DEFINE_boolean 'force' false "force deletion" f DEFINE_boolean 'remote' false "delete remote branch" r # Override defaults with values from config gitflow_override_flag_boolean "feature.delete.force" "force" gitflow_override_flag_boolean "feature.delete.remote" "remote" # Parse arguments parse_args "$@" gitflow_expand_nameprefix_arg # Sanity checks require_branch "$BRANCH" run_pre_hook "$NAME" "$ORIGIN" "$BRANCH" current_branch=$(git_current_branch) # We can't delete a branch we are on, switch to the develop branch. if [ "$BRANCH" = "$current_branch" ]; then require_clean_working_tree git_do checkout "$DEVELOP_BRANCH" || die "Could not check out branch '$DEVELOP_BRANCH'." fi if git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then git_do branch -d "$BRANCH" || die "Could not delete the $BRANCH." if flag remote; then git_do push "$ORIGIN" :"$BRANCH" || die "Could not delete the remote $BRANCH in $ORIGIN." fi else if flag force; then git_do branch -D "$BRANCH" || die "Could not delete the $BRANCH." if flag remote; then git_do push "$ORIGIN" :"$BRANCH" || die "Could not delete the remote $BRANCH in $ORIGIN." fi else die "Feature branch '$BRANCH' has been not been merged yet. Use -f to force the deletion." fi fi gitflow_config_remove_base_section "$BRANCH" run_post_hook "$NAME" "$ORIGIN" "$BRANCH" echo echo "Summary of actions:" echo "- Feature branch '$BRANCH' has been deleted." flag remote && echo "- Feature branch '$BRANCH' in '$ORIGIN' has been deleted." echo "- You are now on branch '$(git_current_branch)'" echo } + FLAGS_PARENT='git flow feature' + '[' -z '' ']' + startswith finish - + '[' finish '!=' finish ']' + '[' -z finish ']' + SUBACTION=finish + shift contains "$SUBACTION" "_" ++ contains finish _ ++ local return ++ case $1 in ++ return=1 ++ return 1 echo "$SUBACTION" |tr '-' '_' ++ echo finish ++ tr - _ + SUBACTION=finish + type cmd_finish + '[' finish '!=' help ']' + '[' feature '!=' init ']' + initialize + require_git_repo + git rev-parse + require_gitflow_initialized + gitflow_is_initialized + gitflow_has_master_configured + local master git config --get gitflow.branch.master ++ git config --get gitflow.branch.master + master=master + '[' master '!=' '' ']' + git_local_branch_exists master + '[' -n master ']' git for-each-ref --format='%(refname:short)' refs/heads/$1 ++ git for-each-ref '--format=%(refname:short)' refs/heads/master + '[' -n master ']' + gitflow_has_develop_configured + local develop git config --get gitflow.branch.develop ++ git config --get gitflow.branch.develop + develop=develop + '[' develop '!=' '' ']' + git_local_branch_exists develop + '[' -n develop ']' git for-each-ref --format='%(refname:short)' refs/heads/$1 ++ git for-each-ref '--format=%(refname:short)' refs/heads/develop + '[' -n develop ']' git config --get gitflow.branch.master ++ git config --get gitflow.branch.master git config --get gitflow.branch.develop ++ git config --get gitflow.branch.develop + '[' master '!=' develop ']' + gitflow_has_prefixes_configured + git config --get gitflow.prefix.feature + git config --get gitflow.prefix.release + git config --get gitflow.prefix.hotfix + git config --get gitflow.prefix.support + git config --get gitflow.prefix.versiontag + gitflow_load_settings git rev-parse --show-toplevel 2>/dev/null ++ git rev-parse --show-toplevel + export GIT_CURRENT_REPO_DIR=/Users/USERNAME/tmp/gitflow + GIT_CURRENT_REPO_DIR=/Users/USERNAME/tmp/gitflow git rev-parse --git-dir 2>/dev/null ++ git rev-parse --git-dir + export DOT_GIT_DIR=.git + DOT_GIT_DIR=.git git config --get gitflow.path.hooks || echo "$DOT_GIT_DIR"/hooks ++ git config --get gitflow.path.hooks + export HOOKS_DIR=.git/hooks + HOOKS_DIR=.git/hooks git config --get gitflow.branch.master ++ git config --get gitflow.branch.master + export MASTER_BRANCH=master + MASTER_BRANCH=master git config --get gitflow.branch.develop ++ git config --get gitflow.branch.develop + export DEVELOP_BRANCH=develop + DEVELOP_BRANCH=develop git config --get gitflow.origin || echo origin ++ git config --get gitflow.origin ++ echo origin + export ORIGIN=origin + ORIGIN=origin + GITFLOW_CONFIG=.git/gitflow_config + '[' -f .git/gitflow_config ']' git config --get gitflow.prefix.feature ++ git config --get gitflow.prefix.feature + PREFIX=feature/ + '[' finish '!=' default ']' + FLAGS_PARENT='git flow feature finish' + cmd_finish f3 '' + OPTIONS_SPEC='git flow feature finish [-h] [-F] [-r] [-p] [-k] [-D] [-S] [--no-ff] Finish feature -- h,help! Show this help 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 k,[no]keep Keep branch after performing finish keepremote! Keep the remote branch keeplocal! Keep the local branch D,[no]force_delete Force delete feature branch after finish S,[no]squash Squash feature during merge no-ff! Never fast-forward during the merge ' + local finish_base + DEFINE_boolean fetch false 'fetch from origin before performing finish' F + _flags_define 1 fetch false 'fetch from origin before performing finish' F + '[' 5 -lt 4 ']' + _flags_type_=1 + _flags_name_=fetch + _flags_default_=false + _flags_help_='fetch from origin before performing finish' + _flags_short_=F + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName fetch ++ _flags_opt_=fetch ++ _flags_isNegate fetch ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo fetch ++ unset _flags_opt_ ++ return 0 + _flags_usName_=fetch _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName fetch ++ echo fetch ++ tr - _ + _flags_usName_=fetch + _flags_itemInList fetch ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=fetch + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a F = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList fetch showcommands noshowcommands showcommands + _flags_str_=fetch + shift + _flags_list_=' showcommands noshowcommands showcommands ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a F '!=' '~' ']' + _flags_itemInList F '~' + _flags_str_=F + shift + _flags_list_=' ~ ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate fetch + case $1 in + flags_return=0 + return 0 + _flags_isNegate_=0 + '[' 0 -eq 0 ']' + eval 'FLAGS_fetch='\''1'\''' FLAGS_fetch='1' ++ FLAGS_fetch=1 + eval __flags_fetch_type=1 __flags_fetch_type=1 ++ __flags_fetch_type=1 + eval '__flags_fetch_default="1"' __flags_fetch_default="1" ++ __flags_fetch_default=1 + eval '__flags_fetch_help="fetch from origin before performing finish"' __flags_fetch_help="fetch from origin before performing finish" ++ __flags_fetch_help='fetch from origin before performing finish' + eval '__flags_fetch_short='\''F'\''' __flags_fetch_short='F' ++ __flags_fetch_short=F + __flags_shortNames=' ~ F ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName fetch ++ _flags_opt_=fetch ++ _flags_isNegate fetch ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo fetch ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch ' + '[' 1 -eq 1 -a 0 -eq 0 ']' + __flags_boolNames=' noshowcommands nofetch ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch ' + '[' 1 -eq 1 ']' + '[' 0 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch ' + '[' 1 -eq 1 ']' + '[' 0 -eq 1 ']' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + DEFINE_boolean rebase false 'rebase before merging' r + _flags_define 1 rebase false 'rebase before merging' r + '[' 5 -lt 4 ']' + _flags_type_=1 + _flags_name_=rebase + _flags_default_=false + _flags_help_='rebase before merging' + _flags_short_=r + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName rebase ++ _flags_opt_=rebase ++ _flags_isNegate rebase ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo rebase ++ unset _flags_opt_ ++ return 0 + _flags_usName_=rebase _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName rebase ++ echo rebase ++ tr - _ + _flags_usName_=rebase + _flags_itemInList rebase ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=rebase + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a r = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList rebase showcommands noshowcommands showcommands fetch nofetch fetch + _flags_str_=rebase + shift + _flags_list_=' showcommands noshowcommands showcommands fetch nofetch fetch ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a r '!=' '~' ']' + _flags_itemInList r '~' F + _flags_str_=r + shift + _flags_list_=' ~ F ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate rebase + case $1 in + flags_return=0 + return 0 + _flags_isNegate_=0 + '[' 0 -eq 0 ']' + eval 'FLAGS_rebase='\''1'\''' FLAGS_rebase='1' ++ FLAGS_rebase=1 + eval __flags_rebase_type=1 __flags_rebase_type=1 ++ __flags_rebase_type=1 + eval '__flags_rebase_default="1"' __flags_rebase_default="1" ++ __flags_rebase_default=1 + eval '__flags_rebase_help="rebase before merging"' __flags_rebase_help="rebase before merging" ++ __flags_rebase_help='rebase before merging' + eval '__flags_rebase_short='\''r'\''' __flags_rebase_short='r' ++ __flags_rebase_short=r + __flags_shortNames=' ~ F r ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName rebase ++ _flags_opt_=rebase ++ _flags_isNegate rebase ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo rebase ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch rebase ' + '[' 1 -eq 1 -a 0 -eq 0 ']' + __flags_boolNames=' noshowcommands nofetch norebase ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase ' + '[' 1 -eq 1 ']' + '[' 0 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase ' + '[' 1 -eq 1 ']' + '[' 0 -eq 1 ']' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + DEFINE_boolean preserve-merges false 'try to recreate merges while rebasing' p + _flags_define 1 preserve-merges false 'try to recreate merges while rebasing' p + '[' 5 -lt 4 ']' + _flags_type_=1 + _flags_name_=preserve-merges + _flags_default_=false + _flags_help_='try to recreate merges while rebasing' + _flags_short_=p + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName preserve-merges ++ _flags_opt_=preserve-merges ++ _flags_isNegate preserve-merges ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo preserve-merges ++ unset _flags_opt_ ++ return 0 + _flags_usName_=preserve-merges _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName preserve-merges ++ echo preserve-merges ++ tr - _ + _flags_usName_=preserve_merges + _flags_itemInList preserve_merges ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=preserve_merges + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a p = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList preserve_merges showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase + _flags_str_=preserve_merges + shift + _flags_list_=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a p '!=' '~' ']' + _flags_itemInList p '~' F r + _flags_str_=p + shift + _flags_list_=' ~ F r ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate preserve-merges + case $1 in + flags_return=0 + return 0 + _flags_isNegate_=0 + '[' 0 -eq 0 ']' + eval 'FLAGS_preserve_merges='\''1'\''' FLAGS_preserve_merges='1' ++ FLAGS_preserve_merges=1 + eval __flags_preserve_merges_type=1 __flags_preserve_merges_type=1 ++ __flags_preserve_merges_type=1 + eval '__flags_preserve_merges_default="1"' __flags_preserve_merges_default="1" ++ __flags_preserve_merges_default=1 + eval '__flags_preserve_merges_help="try to recreate merges while rebasing"' __flags_preserve_merges_help="try to recreate merges while rebasing" ++ __flags_preserve_merges_help='try to recreate merges while rebasing' + eval '__flags_preserve_merges_short='\''p'\''' __flags_preserve_merges_short='p' ++ __flags_preserve_merges_short=p + __flags_shortNames=' ~ F r p ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName preserve-merges ++ _flags_opt_=preserve-merges ++ _flags_isNegate preserve-merges ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo preserve-merges ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch rebase preserve-merges ' + '[' 1 -eq 1 -a 0 -eq 0 ']' + __flags_boolNames=' noshowcommands nofetch norebase nopreserve-merges ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges ' + '[' 1 -eq 1 ']' + '[' 0 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges ' + '[' 1 -eq 1 ']' + '[' 0 -eq 1 ']' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + DEFINE_boolean keep false 'keep branch after performing finish' k + _flags_define 1 keep false 'keep branch after performing finish' k + '[' 5 -lt 4 ']' + _flags_type_=1 + _flags_name_=keep + _flags_default_=false + _flags_help_='keep branch after performing finish' + _flags_short_=k + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName keep ++ _flags_opt_=keep ++ _flags_isNegate keep ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo keep ++ unset _flags_opt_ ++ return 0 + _flags_usName_=keep _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName keep ++ echo keep ++ tr - _ + _flags_usName_=keep + _flags_itemInList keep ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=keep + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a k = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList keep showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges + _flags_str_=keep + shift + _flags_list_=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a k '!=' '~' ']' + _flags_itemInList k '~' F r p + _flags_str_=k + shift + _flags_list_=' ~ F r p ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate keep + case $1 in + flags_return=0 + return 0 + _flags_isNegate_=0 + '[' 0 -eq 0 ']' + eval 'FLAGS_keep='\''1'\''' FLAGS_keep='1' ++ FLAGS_keep=1 + eval __flags_keep_type=1 __flags_keep_type=1 ++ __flags_keep_type=1 + eval '__flags_keep_default="1"' __flags_keep_default="1" ++ __flags_keep_default=1 + eval '__flags_keep_help="keep branch after performing finish"' __flags_keep_help="keep branch after performing finish" ++ __flags_keep_help='keep branch after performing finish' + eval '__flags_keep_short='\''k'\''' __flags_keep_short='k' ++ __flags_keep_short=k + __flags_shortNames=' ~ F r p k ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName keep ++ _flags_opt_=keep ++ _flags_isNegate keep ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo keep ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch rebase preserve-merges keep ' + '[' 1 -eq 1 -a 0 -eq 0 ']' + __flags_boolNames=' noshowcommands nofetch norebase nopreserve-merges nokeep ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep ' + '[' 1 -eq 1 ']' + '[' 0 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep ' + '[' 1 -eq 1 ']' + '[' 0 -eq 1 ']' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + DEFINE_boolean keepremote false 'keep the remote branch' + _flags_define 1 keepremote false 'keep the remote branch' + '[' 4 -lt 4 ']' + _flags_type_=1 + _flags_name_=keepremote + _flags_default_=false + _flags_help_='keep the remote branch' + _flags_short_='~' + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName keepremote ++ _flags_opt_=keepremote ++ _flags_isNegate keepremote ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo keepremote ++ unset _flags_opt_ ++ return 0 + _flags_usName_=keepremote _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName keepremote ++ echo keepremote ++ tr - _ + _flags_usName_=keepremote + _flags_itemInList keepremote ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=keepremote + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a '~' = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList keepremote showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep + _flags_str_=keepremote + shift + _flags_list_=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a '~' '!=' '~' ']' + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate keepremote + case $1 in + flags_return=0 + return 0 + _flags_isNegate_=0 + '[' 0 -eq 0 ']' + eval 'FLAGS_keepremote='\''1'\''' FLAGS_keepremote='1' ++ FLAGS_keepremote=1 + eval __flags_keepremote_type=1 __flags_keepremote_type=1 ++ __flags_keepremote_type=1 + eval '__flags_keepremote_default="1"' __flags_keepremote_default="1" ++ __flags_keepremote_default=1 + eval '__flags_keepremote_help="keep the remote branch"' __flags_keepremote_help="keep the remote branch" ++ __flags_keepremote_help='keep the remote branch' + eval '__flags_keepremote_short='\''~'\''' __flags_keepremote_short='~' ++ __flags_keepremote_short='~' + __flags_shortNames=' ~ F r p k ~ ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName keepremote ++ _flags_opt_=keepremote ++ _flags_isNegate keepremote ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo keepremote ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch rebase preserve-merges keep keepremote ' + '[' 1 -eq 1 -a 0 -eq 0 ']' + __flags_boolNames=' noshowcommands nofetch norebase nopreserve-merges nokeep nokeepremote ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote ' + '[' 1 -eq 1 ']' + '[' 0 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote ' + '[' 1 -eq 1 ']' + '[' 0 -eq 1 ']' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + DEFINE_boolean keeplocal false 'keep the local branch' + _flags_define 1 keeplocal false 'keep the local branch' + '[' 4 -lt 4 ']' + _flags_type_=1 + _flags_name_=keeplocal + _flags_default_=false + _flags_help_='keep the local branch' + _flags_short_='~' + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName keeplocal ++ _flags_opt_=keeplocal ++ _flags_isNegate keeplocal ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo keeplocal ++ unset _flags_opt_ ++ return 0 + _flags_usName_=keeplocal _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName keeplocal ++ echo keeplocal ++ tr - _ + _flags_usName_=keeplocal + _flags_itemInList keeplocal ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=keeplocal + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a '~' = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList keeplocal showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote + _flags_str_=keeplocal + shift + _flags_list_=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a '~' '!=' '~' ']' + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate keeplocal + case $1 in + flags_return=0 + return 0 + _flags_isNegate_=0 + '[' 0 -eq 0 ']' + eval 'FLAGS_keeplocal='\''1'\''' FLAGS_keeplocal='1' ++ FLAGS_keeplocal=1 + eval __flags_keeplocal_type=1 __flags_keeplocal_type=1 ++ __flags_keeplocal_type=1 + eval '__flags_keeplocal_default="1"' __flags_keeplocal_default="1" ++ __flags_keeplocal_default=1 + eval '__flags_keeplocal_help="keep the local branch"' __flags_keeplocal_help="keep the local branch" ++ __flags_keeplocal_help='keep the local branch' + eval '__flags_keeplocal_short='\''~'\''' __flags_keeplocal_short='~' ++ __flags_keeplocal_short='~' + __flags_shortNames=' ~ F r p k ~ ~ ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName keeplocal ++ _flags_opt_=keeplocal ++ _flags_isNegate keeplocal ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo keeplocal ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch rebase preserve-merges keep keepremote keeplocal ' + '[' 1 -eq 1 -a 0 -eq 0 ']' + __flags_boolNames=' noshowcommands nofetch norebase nopreserve-merges nokeep nokeepremote nokeeplocal ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal ' + '[' 1 -eq 1 ']' + '[' 0 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal ' + '[' 1 -eq 1 ']' + '[' 0 -eq 1 ']' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + DEFINE_boolean force_delete false 'force delete feature branch after finish' D + _flags_define 1 force_delete false 'force delete feature branch after finish' D + '[' 5 -lt 4 ']' + _flags_type_=1 + _flags_name_=force_delete + _flags_default_=false + _flags_help_='force delete feature branch after finish' + _flags_short_=D + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName force_delete ++ _flags_opt_=force_delete ++ _flags_isNegate force_delete ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo force_delete ++ unset _flags_opt_ ++ return 0 + _flags_usName_=force_delete _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName force_delete ++ echo force_delete ++ tr - _ + _flags_usName_=force_delete + _flags_itemInList force_delete ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=force_delete + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a D = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList force_delete showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal + _flags_str_=force_delete + shift + _flags_list_=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a D '!=' '~' ']' + _flags_itemInList D '~' F r p k '~' '~' + _flags_str_=D + shift + _flags_list_=' ~ F r p k ~ ~ ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate force_delete + case $1 in + flags_return=0 + return 0 + _flags_isNegate_=0 + '[' 0 -eq 0 ']' + eval 'FLAGS_force_delete='\''1'\''' FLAGS_force_delete='1' ++ FLAGS_force_delete=1 + eval __flags_force_delete_type=1 __flags_force_delete_type=1 ++ __flags_force_delete_type=1 + eval '__flags_force_delete_default="1"' __flags_force_delete_default="1" ++ __flags_force_delete_default=1 + eval '__flags_force_delete_help="force delete feature branch after finish"' __flags_force_delete_help="force delete feature branch after finish" ++ __flags_force_delete_help='force delete feature branch after finish' + eval '__flags_force_delete_short='\''D'\''' __flags_force_delete_short='D' ++ __flags_force_delete_short=D + __flags_shortNames=' ~ F r p k ~ ~ D ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName force_delete ++ _flags_opt_=force_delete ++ _flags_isNegate force_delete ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo force_delete ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch rebase preserve-merges keep keepremote keeplocal force_delete ' + '[' 1 -eq 1 -a 0 -eq 0 ']' + __flags_boolNames=' noshowcommands nofetch norebase nopreserve-merges nokeep nokeepremote nokeeplocal noforce_delete ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete ' + '[' 1 -eq 1 ']' + '[' 0 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete ' + '[' 1 -eq 1 ']' + '[' 0 -eq 1 ']' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + DEFINE_boolean squash false 'squash feature during merge' S + _flags_define 1 squash false 'squash feature during merge' S + '[' 5 -lt 4 ']' + _flags_type_=1 + _flags_name_=squash + _flags_default_=false + _flags_help_='squash feature during merge' + _flags_short_=S + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName squash ++ _flags_opt_=squash ++ _flags_isNegate squash ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo squash ++ unset _flags_opt_ ++ return 0 + _flags_usName_=squash _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName squash ++ tr - _ ++ echo squash + _flags_usName_=squash + _flags_itemInList squash ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=squash + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a S = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList squash showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete + _flags_str_=squash + shift + _flags_list_=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a S '!=' '~' ']' + _flags_itemInList S '~' F r p k '~' '~' D + _flags_str_=S + shift + _flags_list_=' ~ F r p k ~ ~ D ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate squash + case $1 in + flags_return=0 + return 0 + _flags_isNegate_=0 + '[' 0 -eq 0 ']' + eval 'FLAGS_squash='\''1'\''' FLAGS_squash='1' ++ FLAGS_squash=1 + eval __flags_squash_type=1 __flags_squash_type=1 ++ __flags_squash_type=1 + eval '__flags_squash_default="1"' __flags_squash_default="1" ++ __flags_squash_default=1 + eval '__flags_squash_help="squash feature during merge"' __flags_squash_help="squash feature during merge" ++ __flags_squash_help='squash feature during merge' + eval '__flags_squash_short='\''S'\''' __flags_squash_short='S' ++ __flags_squash_short=S + __flags_shortNames=' ~ F r p k ~ ~ D S ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName squash ++ _flags_opt_=squash ++ _flags_isNegate squash ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo squash ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch rebase preserve-merges keep keepremote keeplocal force_delete squash ' + '[' 1 -eq 1 -a 0 -eq 0 ']' + __flags_boolNames=' noshowcommands nofetch norebase nopreserve-merges nokeep nokeepremote nokeeplocal noforce_delete nosquash ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash ' + '[' 1 -eq 1 ']' + '[' 0 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash ' + '[' 1 -eq 1 ']' + '[' 0 -eq 1 ']' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + DEFINE_boolean squash-info false 'add branch info during squash' + _flags_define 1 squash-info false 'add branch info during squash' + '[' 4 -lt 4 ']' + _flags_type_=1 + _flags_name_=squash-info + _flags_default_=false + _flags_help_='add branch info during squash' + _flags_short_='~' + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName squash-info ++ _flags_opt_=squash-info ++ _flags_isNegate squash-info ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo squash-info ++ unset _flags_opt_ ++ return 0 + _flags_usName_=squash-info _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName squash-info ++ echo squash-info ++ tr - _ + _flags_usName_=squash_info + _flags_itemInList squash_info ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=squash_info + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a '~' = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList squash_info showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash + _flags_str_=squash_info + shift + _flags_list_=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a '~' '!=' '~' ']' + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate squash-info + case $1 in + flags_return=0 + return 0 + _flags_isNegate_=0 + '[' 0 -eq 0 ']' + eval 'FLAGS_squash_info='\''1'\''' FLAGS_squash_info='1' ++ FLAGS_squash_info=1 + eval __flags_squash_info_type=1 __flags_squash_info_type=1 ++ __flags_squash_info_type=1 + eval '__flags_squash_info_default="1"' __flags_squash_info_default="1" ++ __flags_squash_info_default=1 + eval '__flags_squash_info_help="add branch info during squash"' __flags_squash_info_help="add branch info during squash" ++ __flags_squash_info_help='add branch info during squash' + eval '__flags_squash_info_short='\''~'\''' __flags_squash_info_short='~' ++ __flags_squash_info_short='~' + __flags_shortNames=' ~ F r p k ~ ~ D S ~ ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName squash-info ++ _flags_opt_=squash-info ++ _flags_isNegate squash-info ++ case $1 in ++ flags_return=0 ++ return 0 ++ echo squash-info ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch rebase preserve-merges keep keepremote keeplocal force_delete squash squash-info ' + '[' 1 -eq 1 -a 0 -eq 0 ']' + __flags_boolNames=' noshowcommands nofetch norebase nopreserve-merges nokeep nokeepremote nokeeplocal noforce_delete nosquash nosquash-info ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info ' + '[' 1 -eq 1 ']' + '[' 0 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info nosquash_info ' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info nosquash_info squash_info ' + '[' 1 -eq 1 ']' + '[' 0 -eq 1 ']' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + DEFINE_boolean 'no-ff!' false 'Don'\''t fast-forward ever during merge ' + _flags_define 1 'no-ff!' false 'Don'\''t fast-forward ever during merge ' + '[' 4 -lt 4 ']' + _flags_type_=1 + _flags_name_='no-ff!' + _flags_default_=false + _flags_help_='Don'\''t fast-forward ever during merge ' + _flags_short_='~' + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName 'no-ff!' ++ _flags_opt_='no-ff!' ++ _flags_isNegate 'no-ff!' ++ case $1 in ++ flags_return=1 ++ return 1 ++ _flags_useBuiltin ++ return 0 ++ echo no-ff ++ unset _flags_opt_ ++ return 0 + _flags_usName_=no-ff _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName no-ff ++ echo no-ff ++ tr - _ + _flags_usName_=no_ff + _flags_itemInList no_ff ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=no_ff + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a '~' = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList no_ff showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info nosquash_info squash_info + _flags_str_=no_ff + shift + _flags_list_=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info nosquash_info squash_info ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a '~' '!=' '~' ']' + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate 'no-ff!' + case $1 in + flags_return=1 + return 1 + _flags_isNegate_=1 + '[' 0 -eq 0 ']' + eval 'FLAGS_no_ff='\''1'\''' FLAGS_no_ff='1' ++ FLAGS_no_ff=1 + eval __flags_no_ff_type=1 __flags_no_ff_type=1 ++ __flags_no_ff_type=1 + eval '__flags_no_ff_default="1"' __flags_no_ff_default="1" ++ __flags_no_ff_default=1 + eval '__flags_no_ff_help="Don'\''t fast-forward ever during merge "' __flags_no_ff_help="Don't fast-forward ever during merge " ++ __flags_no_ff_help='Don'\''t fast-forward ever during merge ' + eval '__flags_no_ff_short='\''~'\''' __flags_no_ff_short='~' ++ __flags_no_ff_short='~' + __flags_shortNames=' ~ F r p k ~ ~ D S ~ ~ ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName 'no-ff!' ++ _flags_opt_='no-ff!' ++ _flags_isNegate 'no-ff!' ++ case $1 in ++ flags_return=1 ++ return 1 ++ _flags_useBuiltin ++ return 0 ++ echo no-ff ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch rebase preserve-merges keep keepremote keeplocal force_delete squash squash-info no-ff ' + '[' 1 -eq 1 -a 1 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info nosquash_info squash_info no_ff ' + '[' 1 -eq 1 ']' + '[' 1 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info nosquash_info squash_info no_ff no_ff ' + '[' 1 -eq 1 ']' + '[' 1 -eq 1 ']' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName 'no-ff!' ++ _flags_opt_='no-ff!' ++ _flags_isNegate 'no-ff!' ++ case $1 in ++ flags_return=1 ++ return 1 ++ _flags_useBuiltin ++ return 0 ++ echo no-ff ++ unset _flags_opt_ ++ return 0 + __flags_nonegateNames=' no-ff ' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + gitflow_override_flag_boolean feature.finish.fetch fetch + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.feature.finish.fetch + _variable= + case $? in + unset _variable + return 0 + gitflow_override_flag_boolean feature.finish.rebase rebase + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.feature.finish.rebase + _variable= + case $? in + unset _variable + return 0 + gitflow_override_flag_boolean feature.finish.preserve-merges preserve_merges + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.feature.finish.preserve-merges + _variable= + case $? in + unset _variable + return 0 + gitflow_override_flag_boolean feature.finish.keep keep + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.feature.finish.keep + _variable= + case $? in + unset _variable + return 0 + gitflow_override_flag_boolean feature.finish.keepremote keepremote + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.feature.finish.keepremote + _variable= + case $? in + unset _variable + return 0 + gitflow_override_flag_boolean feature.finish.keeplocal keeplocal + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.feature.finish.keeplocal + _variable= + case $? in + unset _variable + return 0 + gitflow_override_flag_boolean feature.finish.force-delete force_delete + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.feature.finish.force-delete + _variable= + case $? in + unset _variable + return 0 + gitflow_override_flag_boolean feature.finish.squash squash + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.feature.finish.squash + _variable= + case $? in + unset _variable + return 0 + gitflow_override_flag_boolean feature.finish.squash-info squash_info + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.feature.finish.squash-info + _variable= + case $? in + unset _variable + return 0 + gitflow_override_flag_boolean feature.finish.no-ff no_ff + local _variable git config --bool --get gitflow.$1 2>&1 ++ git config --bool --get gitflow.feature.finish.no-ff + _variable= + case $? in + unset _variable + return 0 + parse_args f3 '' + FLAGS f3 '' + '[' -z '' ']' + DEFINE_boolean 'help!' false 'show this help' h + _flags_define 1 'help!' false 'show this help' h + '[' 5 -lt 4 ']' + _flags_type_=1 + _flags_name_='help!' + _flags_default_=false + _flags_help_='show this help' + _flags_short_=h + _flags_return_=0 _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName 'help!' ++ _flags_opt_='help!' ++ _flags_isNegate 'help!' ++ case $1 in ++ flags_return=1 ++ return 1 ++ _flags_useBuiltin ++ return 0 ++ echo help ++ unset _flags_opt_ ++ return 0 + _flags_usName_=help _flags_underscoreName ${_flags_usName_} ++ _flags_underscoreName help ++ echo help ++ tr - _ + _flags_usName_=help + _flags_itemInList help ' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + _flags_str_=help + shift + _flags_list_=' ARGC ARGV ERROR FALSE GETOPT_CMD HELP PARENT TRUE VERSION ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 1 -eq 0 ']' + '[' 0 -eq 0 -a 1 -ne 1 -a h = '~' ']' + '[' 0 -eq 0 ']' + _flags_itemInList help showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info nosquash_info squash_info no_ff no_ff + _flags_str_=help + shift + _flags_list_=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info nosquash_info squash_info no_ff no_ff ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 -a h '!=' '~' ']' + _flags_itemInList h '~' F r p k '~' '~' D S '~' '~' + _flags_str_=h + shift + _flags_list_=' ~ F r p k ~ ~ D S ~ ~ ' + case ${_flags_list_} in + flags_return=1 + unset _flags_str_ _flags_list_ + return 1 + '[' 0 -eq 0 ']' + case ${_flags_type_} in + _flags_validBool false + _flags_bool_=false + flags_return=0 + case "${_flags_bool_}" in + unset _flags_bool_ + return 0 + case ${_flags_default_} in + _flags_default_=1 + _flags_isNegate 'help!' + case $1 in + flags_return=1 + return 1 + _flags_isNegate_=1 + '[' 0 -eq 0 ']' + eval 'FLAGS_help='\''1'\''' FLAGS_help='1' ++ FLAGS_help=1 + eval __flags_help_type=1 __flags_help_type=1 ++ __flags_help_type=1 + eval '__flags_help_default="1"' __flags_help_default="1" ++ __flags_help_default=1 + eval '__flags_help_help="show this help"' __flags_help_help="show this help" ++ __flags_help_help='show this help' + eval '__flags_help_short='\''h'\''' __flags_help_short='h' ++ __flags_help_short=h + __flags_shortNames=' ~ F r p k ~ ~ D S ~ ~ h ' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName 'help!' ++ _flags_opt_='help!' ++ _flags_isNegate 'help!' ++ case $1 in ++ flags_return=1 ++ return 1 ++ _flags_useBuiltin ++ return 0 ++ echo help ++ unset _flags_opt_ ++ return 0 + __flags_longNames=' showcommands fetch rebase preserve-merges keep keepremote keeplocal force_delete squash squash-info no-ff help ' + '[' 1 -eq 1 -a 1 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info nosquash_info squash_info no_ff no_ff help ' + '[' 1 -eq 1 ']' + '[' 1 -eq 0 ']' + __flags_definedNames=' showcommands noshowcommands showcommands fetch nofetch fetch rebase norebase rebase preserve_merges nopreserve_merges preserve_merges keep nokeep keep keepremote nokeepremote keepremote keeplocal nokeeplocal keeplocal force_delete noforce_delete force_delete squash nosquash squash squash_info nosquash_info squash_info no_ff no_ff help help ' + '[' 1 -eq 1 ']' + '[' 1 -eq 1 ']' _flags_removeExclamationName ${_flags_name_} ++ _flags_removeExclamationName 'help!' ++ _flags_opt_='help!' ++ _flags_isNegate 'help!' ++ case $1 in ++ flags_return=1 ++ return 1 ++ _flags_useBuiltin ++ return 0 ++ echo help ++ unset _flags_opt_ ++ return 0 + __flags_nonegateNames=' no-ff help ' + flags_return=0 + unset _flags_default_ _flags_help_ _flags_name_ _flags_return_ _flags_short_ _flags_type_ _flags_usName_ + '[' 0 -eq 2 ']' + return 0 + '[' 2 -gt 0 ']' + '[' 1 -ne 1 ']' + _flags_getoptEnhanced f3 '' + flags_return=0 _flags_genOptStr ${__FLAGS_OPTSTR_SHORT} ++ _flags_genOptStr 0 ++ _flags_optStrType_=0 ++ _flags_opts_= ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName showcommands +++ _flags_opt_=showcommands +++ _flags_isNegate showcommands +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo showcommands +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=showcommands _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName showcommands +++ echo showcommands +++ tr - _ ++ _flags_usName_=showcommands _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo showcommands type +++ _flags_gFI_usName_=showcommands +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_showcommands_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_showcommands_type:-}"' +++ eval '_flags_infoValue_="${__flags_showcommands_type:-}"' _flags_infoValue_="${__flags_showcommands_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo showcommands short +++ _flags_gFI_usName_=showcommands +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_showcommands_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_showcommands_short:-}"' +++ eval '_flags_infoValue_="${__flags_showcommands_short:-}"' _flags_infoValue_="${__flags_showcommands_short:-}" ++++ _flags_infoValue_='~' +++ '[' -n '~' ']' +++ flags_return=0 +++ echo '~' +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_='~' ++ '[' '~' '!=' '~' ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName fetch +++ _flags_opt_=fetch +++ _flags_isNegate fetch +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo fetch +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=fetch _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName fetch +++ echo fetch +++ tr - _ ++ _flags_usName_=fetch _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo fetch type +++ _flags_gFI_usName_=fetch +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_fetch_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_fetch_type:-}"' +++ eval '_flags_infoValue_="${__flags_fetch_type:-}"' _flags_infoValue_="${__flags_fetch_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo fetch short +++ _flags_gFI_usName_=fetch +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_fetch_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_fetch_short:-}"' +++ eval '_flags_infoValue_="${__flags_fetch_short:-}"' _flags_infoValue_="${__flags_fetch_short:-}" ++++ _flags_infoValue_=F +++ '[' -n F ']' +++ flags_return=0 +++ echo F +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_=F ++ '[' F '!=' '~' ']' ++ _flags_opts_=F ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName rebase +++ _flags_opt_=rebase +++ _flags_isNegate rebase +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo rebase +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=rebase _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName rebase +++ echo rebase +++ tr - _ ++ _flags_usName_=rebase _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo rebase type +++ _flags_gFI_usName_=rebase +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_rebase_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_rebase_type:-}"' +++ eval '_flags_infoValue_="${__flags_rebase_type:-}"' _flags_infoValue_="${__flags_rebase_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo rebase short +++ _flags_gFI_usName_=rebase +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_rebase_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_rebase_short:-}"' +++ eval '_flags_infoValue_="${__flags_rebase_short:-}"' _flags_infoValue_="${__flags_rebase_short:-}" ++++ _flags_infoValue_=r +++ '[' -n r ']' +++ flags_return=0 +++ echo r +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_=r ++ '[' r '!=' '~' ']' ++ _flags_opts_=Fr ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName preserve-merges +++ _flags_opt_=preserve-merges +++ _flags_isNegate preserve-merges +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo preserve-merges +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=preserve-merges _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName preserve-merges +++ echo preserve-merges +++ tr - _ ++ _flags_usName_=preserve_merges _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo preserve_merges type +++ _flags_gFI_usName_=preserve_merges +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_preserve_merges_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_preserve_merges_type:-}"' +++ eval '_flags_infoValue_="${__flags_preserve_merges_type:-}"' _flags_infoValue_="${__flags_preserve_merges_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo preserve_merges short +++ _flags_gFI_usName_=preserve_merges +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_preserve_merges_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_preserve_merges_short:-}"' +++ eval '_flags_infoValue_="${__flags_preserve_merges_short:-}"' _flags_infoValue_="${__flags_preserve_merges_short:-}" ++++ _flags_infoValue_=p +++ '[' -n p ']' +++ flags_return=0 +++ echo p +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_=p ++ '[' p '!=' '~' ']' ++ _flags_opts_=Frp ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName keep +++ _flags_opt_=keep +++ _flags_isNegate keep +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo keep +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=keep _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName keep +++ echo keep +++ tr - _ ++ _flags_usName_=keep _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo keep type +++ _flags_gFI_usName_=keep +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_keep_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_keep_type:-}"' +++ eval '_flags_infoValue_="${__flags_keep_type:-}"' _flags_infoValue_="${__flags_keep_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo keep short +++ _flags_gFI_usName_=keep +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_keep_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_keep_short:-}"' +++ eval '_flags_infoValue_="${__flags_keep_short:-}"' _flags_infoValue_="${__flags_keep_short:-}" ++++ _flags_infoValue_=k +++ '[' -n k ']' +++ flags_return=0 +++ echo k +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_=k ++ '[' k '!=' '~' ']' ++ _flags_opts_=Frpk ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName keepremote +++ _flags_opt_=keepremote +++ _flags_isNegate keepremote +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo keepremote +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=keepremote _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName keepremote +++ echo keepremote +++ tr - _ ++ _flags_usName_=keepremote _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo keepremote type +++ _flags_gFI_usName_=keepremote +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_keepremote_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_keepremote_type:-}"' +++ eval '_flags_infoValue_="${__flags_keepremote_type:-}"' _flags_infoValue_="${__flags_keepremote_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo keepremote short +++ _flags_gFI_usName_=keepremote +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_keepremote_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_keepremote_short:-}"' +++ eval '_flags_infoValue_="${__flags_keepremote_short:-}"' _flags_infoValue_="${__flags_keepremote_short:-}" ++++ _flags_infoValue_='~' +++ '[' -n '~' ']' +++ flags_return=0 +++ echo '~' +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_='~' ++ '[' '~' '!=' '~' ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName keeplocal +++ _flags_opt_=keeplocal +++ _flags_isNegate keeplocal +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo keeplocal +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=keeplocal _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName keeplocal +++ echo keeplocal +++ tr - _ ++ _flags_usName_=keeplocal _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo keeplocal type +++ _flags_gFI_usName_=keeplocal +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_keeplocal_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_keeplocal_type:-}"' +++ eval '_flags_infoValue_="${__flags_keeplocal_type:-}"' _flags_infoValue_="${__flags_keeplocal_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo keeplocal short +++ _flags_gFI_usName_=keeplocal +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_keeplocal_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_keeplocal_short:-}"' +++ eval '_flags_infoValue_="${__flags_keeplocal_short:-}"' _flags_infoValue_="${__flags_keeplocal_short:-}" ++++ _flags_infoValue_='~' +++ '[' -n '~' ']' +++ flags_return=0 +++ echo '~' +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_='~' ++ '[' '~' '!=' '~' ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName force_delete +++ _flags_opt_=force_delete +++ _flags_isNegate force_delete +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo force_delete +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=force_delete _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName force_delete +++ echo force_delete +++ tr - _ ++ _flags_usName_=force_delete _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo force_delete type +++ _flags_gFI_usName_=force_delete +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_force_delete_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_force_delete_type:-}"' +++ eval '_flags_infoValue_="${__flags_force_delete_type:-}"' _flags_infoValue_="${__flags_force_delete_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo force_delete short +++ _flags_gFI_usName_=force_delete +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_force_delete_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_force_delete_short:-}"' +++ eval '_flags_infoValue_="${__flags_force_delete_short:-}"' _flags_infoValue_="${__flags_force_delete_short:-}" ++++ _flags_infoValue_=D +++ '[' -n D ']' +++ flags_return=0 +++ echo D +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_=D ++ '[' D '!=' '~' ']' ++ _flags_opts_=FrpkD ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName squash +++ _flags_opt_=squash +++ _flags_isNegate squash +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo squash +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=squash _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName squash +++ echo squash +++ tr - _ ++ _flags_usName_=squash _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo squash type +++ _flags_gFI_usName_=squash +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_squash_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_squash_type:-}"' +++ eval '_flags_infoValue_="${__flags_squash_type:-}"' _flags_infoValue_="${__flags_squash_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo squash short +++ _flags_gFI_usName_=squash +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_squash_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_squash_short:-}"' +++ eval '_flags_infoValue_="${__flags_squash_short:-}"' _flags_infoValue_="${__flags_squash_short:-}" ++++ _flags_infoValue_=S +++ '[' -n S ']' +++ flags_return=0 +++ echo S +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_=S ++ '[' S '!=' '~' ']' ++ _flags_opts_=FrpkDS ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName squash-info +++ _flags_opt_=squash-info +++ _flags_isNegate squash-info +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo squash-info +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=squash-info _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName squash-info +++ echo squash-info +++ tr - _ ++ _flags_usName_=squash_info _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo squash_info type +++ _flags_gFI_usName_=squash_info +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_squash_info_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_squash_info_type:-}"' +++ eval '_flags_infoValue_="${__flags_squash_info_type:-}"' _flags_infoValue_="${__flags_squash_info_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo squash_info short +++ _flags_gFI_usName_=squash_info +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_squash_info_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_squash_info_short:-}"' +++ eval '_flags_infoValue_="${__flags_squash_info_short:-}"' _flags_infoValue_="${__flags_squash_info_short:-}" ++++ _flags_infoValue_='~' +++ '[' -n '~' ']' +++ flags_return=0 +++ echo '~' +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_='~' ++ '[' '~' '!=' '~' ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName no-ff +++ _flags_opt_=no-ff +++ _flags_isNegate no-ff +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo no-ff +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=no-ff _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName no-ff +++ echo no-ff +++ tr - _ ++ _flags_usName_=no_ff _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo no_ff type +++ _flags_gFI_usName_=no_ff +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_no_ff_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_no_ff_type:-}"' +++ eval '_flags_infoValue_="${__flags_no_ff_type:-}"' _flags_infoValue_="${__flags_no_ff_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo no_ff short +++ _flags_gFI_usName_=no_ff +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_no_ff_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_no_ff_short:-}"' +++ eval '_flags_infoValue_="${__flags_no_ff_short:-}"' _flags_infoValue_="${__flags_no_ff_short:-}" ++++ _flags_infoValue_='~' +++ '[' -n '~' ']' +++ flags_return=0 +++ echo '~' +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_='~' ++ '[' '~' '!=' '~' ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName help +++ _flags_opt_=help +++ _flags_isNegate help +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo help +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=help _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName help +++ echo help +++ tr - _ ++ _flags_usName_=help _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo help type +++ _flags_gFI_usName_=help +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_help_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_help_type:-}"' +++ eval '_flags_infoValue_="${__flags_help_type:-}"' _flags_infoValue_="${__flags_help_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_SHORT} +++ _flags_getFlagInfo help short +++ _flags_gFI_usName_=help +++ _flags_gFI_info_=short +++ _flags_infoVar_=__flags_help_short +++ _flags_strToEval_='_flags_infoValue_="${__flags_help_short:-}"' +++ eval '_flags_infoValue_="${__flags_help_short:-}"' _flags_infoValue_="${__flags_help_short:-}" ++++ _flags_infoValue_=h +++ '[' -n h ']' +++ flags_return=0 +++ echo h +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_shortName_=h ++ '[' h '!=' '~' ']' ++ _flags_opts_=FrpkDSh ++ '[' 1 -ne 1 ']' ++ echo FrpkDSh ++ unset _flags_name_ _flags_opts_ _flags_optStrType_ _flags_shortName_ _flags_type_ _flags_usName_ ++ return 0 + _flags_shortOpts_=FrpkDSh echo "${__flags_boolNames}" |sed 's/^ *//;s/ *$//;s/ /,/g' ++ echo ' noshowcommands nofetch norebase nopreserve-merges nokeep nokeepremote nokeeplocal noforce_delete nosquash nosquash-info ' ++ sed 's/^ *//;s/ *$//;s/ /,/g' + _flags_boolOpts_=noshowcommands,nofetch,norebase,nopreserve-merges,nokeep,nokeepremote,nokeeplocal,noforce_delete,nosquash,nosquash-info _flags_genOptStr ${__FLAGS_OPTSTR_LONG} ++ _flags_genOptStr 1 ++ _flags_optStrType_=1 ++ _flags_opts_= ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName showcommands +++ _flags_opt_=showcommands +++ _flags_isNegate showcommands +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo showcommands +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=showcommands _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName showcommands +++ echo showcommands +++ tr - _ ++ _flags_usName_=showcommands _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo showcommands type +++ _flags_gFI_usName_=showcommands +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_showcommands_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_showcommands_type:-}"' +++ eval '_flags_infoValue_="${__flags_showcommands_type:-}"' _flags_infoValue_="${__flags_showcommands_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName showcommands +++ _flags_opt_=showcommands +++ _flags_isNegate showcommands +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo showcommands +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName fetch +++ _flags_opt_=fetch +++ _flags_isNegate fetch +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo fetch +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=fetch _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName fetch +++ echo fetch +++ tr - _ ++ _flags_usName_=fetch _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo fetch type +++ _flags_gFI_usName_=fetch +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_fetch_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_fetch_type:-}"' +++ eval '_flags_infoValue_="${__flags_fetch_type:-}"' _flags_infoValue_="${__flags_fetch_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName fetch +++ _flags_opt_=fetch +++ _flags_isNegate fetch +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo fetch +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName rebase +++ _flags_opt_=rebase +++ _flags_isNegate rebase +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo rebase +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=rebase _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName rebase +++ echo rebase +++ tr - _ ++ _flags_usName_=rebase _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo rebase type +++ _flags_gFI_usName_=rebase +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_rebase_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_rebase_type:-}"' +++ eval '_flags_infoValue_="${__flags_rebase_type:-}"' _flags_infoValue_="${__flags_rebase_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName rebase +++ _flags_opt_=rebase +++ _flags_isNegate rebase +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo rebase +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch,rebase ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName preserve-merges +++ _flags_opt_=preserve-merges +++ _flags_isNegate preserve-merges +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo preserve-merges +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=preserve-merges _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName preserve-merges +++ echo preserve-merges +++ tr - _ ++ _flags_usName_=preserve_merges _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo preserve_merges type +++ _flags_gFI_usName_=preserve_merges +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_preserve_merges_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_preserve_merges_type:-}"' +++ eval '_flags_infoValue_="${__flags_preserve_merges_type:-}"' _flags_infoValue_="${__flags_preserve_merges_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName preserve-merges +++ _flags_opt_=preserve-merges +++ _flags_isNegate preserve-merges +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo preserve-merges +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch,rebase,preserve-merges ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName keep +++ _flags_opt_=keep +++ _flags_isNegate keep +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo keep +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=keep _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName keep +++ tr - _ +++ echo keep ++ _flags_usName_=keep _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo keep type +++ _flags_gFI_usName_=keep +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_keep_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_keep_type:-}"' +++ eval '_flags_infoValue_="${__flags_keep_type:-}"' _flags_infoValue_="${__flags_keep_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName keep +++ _flags_opt_=keep +++ _flags_isNegate keep +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo keep +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch,rebase,preserve-merges,keep ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName keepremote +++ _flags_opt_=keepremote +++ _flags_isNegate keepremote +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo keepremote +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=keepremote _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName keepremote +++ echo keepremote +++ tr - _ ++ _flags_usName_=keepremote _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo keepremote type +++ _flags_gFI_usName_=keepremote +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_keepremote_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_keepremote_type:-}"' +++ eval '_flags_infoValue_="${__flags_keepremote_type:-}"' _flags_infoValue_="${__flags_keepremote_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName keepremote +++ _flags_opt_=keepremote +++ _flags_isNegate keepremote +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo keepremote +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch,rebase,preserve-merges,keep,keepremote ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName keeplocal +++ _flags_opt_=keeplocal +++ _flags_isNegate keeplocal +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo keeplocal +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=keeplocal _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName keeplocal +++ echo keeplocal +++ tr - _ ++ _flags_usName_=keeplocal _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo keeplocal type +++ _flags_gFI_usName_=keeplocal +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_keeplocal_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_keeplocal_type:-}"' +++ eval '_flags_infoValue_="${__flags_keeplocal_type:-}"' _flags_infoValue_="${__flags_keeplocal_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName keeplocal +++ _flags_opt_=keeplocal +++ _flags_isNegate keeplocal +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo keeplocal +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch,rebase,preserve-merges,keep,keepremote,keeplocal ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName force_delete +++ _flags_opt_=force_delete +++ _flags_isNegate force_delete +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo force_delete +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=force_delete _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName force_delete +++ echo force_delete +++ tr - _ ++ _flags_usName_=force_delete _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo force_delete type +++ _flags_gFI_usName_=force_delete +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_force_delete_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_force_delete_type:-}"' +++ eval '_flags_infoValue_="${__flags_force_delete_type:-}"' _flags_infoValue_="${__flags_force_delete_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName force_delete +++ _flags_opt_=force_delete +++ _flags_isNegate force_delete +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo force_delete +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch,rebase,preserve-merges,keep,keepremote,keeplocal,force_delete ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName squash +++ _flags_opt_=squash +++ _flags_isNegate squash +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo squash +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=squash _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName squash +++ echo squash +++ tr - _ ++ _flags_usName_=squash _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo squash type +++ _flags_gFI_usName_=squash +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_squash_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_squash_type:-}"' +++ eval '_flags_infoValue_="${__flags_squash_type:-}"' _flags_infoValue_="${__flags_squash_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName squash +++ _flags_opt_=squash +++ _flags_isNegate squash +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo squash +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch,rebase,preserve-merges,keep,keepremote,keeplocal,force_delete,squash ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName squash-info +++ _flags_opt_=squash-info +++ _flags_isNegate squash-info +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo squash-info +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=squash-info _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName squash-info +++ echo squash-info +++ tr - _ ++ _flags_usName_=squash_info _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo squash_info type +++ _flags_gFI_usName_=squash_info +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_squash_info_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_squash_info_type:-}"' +++ eval '_flags_infoValue_="${__flags_squash_info_type:-}"' _flags_infoValue_="${__flags_squash_info_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName squash-info +++ _flags_opt_=squash-info +++ _flags_isNegate squash-info +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo squash-info +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch,rebase,preserve-merges,keep,keepremote,keeplocal,force_delete,squash,squash-info ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName no-ff +++ _flags_opt_=no-ff +++ _flags_isNegate no-ff +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo no-ff +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=no-ff _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName no-ff +++ echo no-ff +++ tr - _ ++ _flags_usName_=no_ff _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo no_ff type +++ _flags_gFI_usName_=no_ff +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_no_ff_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_no_ff_type:-}"' +++ eval '_flags_infoValue_="${__flags_no_ff_type:-}"' _flags_infoValue_="${__flags_no_ff_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName no-ff +++ _flags_opt_=no-ff +++ _flags_isNegate no-ff +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo no-ff +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch,rebase,preserve-merges,keep,keepremote,keeplocal,force_delete,squash,squash-info,no-ff ++ '[' 1 -ne 1 ']' ++ for _flags_name_ in '${__flags_longNames}' _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName help +++ _flags_opt_=help +++ _flags_isNegate help +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo help +++ unset _flags_opt_ +++ return 0 ++ _flags_usName_=help _flags_underscoreName ${_flags_usName_} +++ _flags_underscoreName help +++ echo help +++ tr - _ ++ _flags_usName_=help _flags_getFlagInfo ${_flags_usName_} ${__FLAGS_INFO_TYPE} +++ _flags_getFlagInfo help type +++ _flags_gFI_usName_=help +++ _flags_gFI_info_=type +++ _flags_infoVar_=__flags_help_type +++ _flags_strToEval_='_flags_infoValue_="${__flags_help_type:-}"' +++ eval '_flags_infoValue_="${__flags_help_type:-}"' _flags_infoValue_="${__flags_help_type:-}" ++++ _flags_infoValue_=1 +++ '[' -n 1 ']' +++ flags_return=0 +++ echo 1 +++ unset _flags_gFI_usName_ _flags_gfI_info_ _flags_infoValue_ _flags_infoVar_ _flags_strToEval_ _flags_typeValue_ _flags_typeVar_ +++ '[' 0 -eq 2 ']' +++ return 0 ++ _flags_type_=1 ++ '[' 0 -eq 0 ']' ++ case ${_flags_optStrType_} in _flags_removeExclamationName ${_flags_name_} +++ _flags_removeExclamationName help +++ _flags_opt_=help +++ _flags_isNegate help +++ case $1 in +++ flags_return=0 +++ return 0 +++ echo help +++ unset _flags_opt_ +++ return 0 ++ _flags_opts_=showcommands,fetch,rebase,preserve-merges,keep,keepremote,keeplocal,force_delete,squash,squash-info,no-ff,help ++ '[' 1 -ne 1 ']' ++ echo showcommands,fetch,rebase,preserve-merges,keep,keepremote,keeplocal,force_delete,squash,squash-info,no-ff,help ++ unset _flags_name_ _flags_opts_ _flags_optStrType_ _flags_shortName_ _flags_type_ _flags_usName_ ++ return 0 + _flags_longOpts_=showcommands,fetch,rebase,preserve-merges,keep,keepremote,keeplocal,force_delete,squash,squash-info,no-ff,help ${FLAGS_GETOPT_CMD} -o ${_flags_shortOpts_} -l "${_flags_longOpts_},${_flags_boolOpts_}" -- "$@" 2>&1 ++ getopt -o FrpkDSh -l showcommands,fetch,rebase,preserve-merges,keep,keepremote,keeplocal,force_delete,squash,squash-info,no-ff,help,noshowcommands,nofetch,norebase,nopreserve-merges,nokeep,nokeepremote,nokeeplocal,noforce_delete,nosquash,nosquash-info -- f3 '' + __flags_opts=' -- '\''f3'\'' '\'''\''' + _flags_rtrn_=0 + '[' 0 -ne 0 ']' + unset _flags_boolOpts_ _flags_longOpts_ _flags_rtrn_ _flags_shortOpts_ + return 0 + flags_return=0 + '[' 0 -eq 0 ']' + _flags_parseGetopt 2 ' -- '\''f3'\'' '\'''\''' + _flags_argc_=2 + shift + flags_return=0 + '[' 1 -ne 1 ']' + eval set -- ' -- '\''f3'\'' '\'''\''' set -- -- 'f3' '' ++ set -- -- f3 '' _flags_math "$# - 1 - ${_flags_argc_}" ++ _flags_math '3 - 1 - 2' ++ '[' 1 -eq 0 ']' ++ _flags_useBuiltin ++ return 0 ++ _flags_expr_='$(($@))' ++ eval echo '$(($@))' echo $(($@)) +++ echo 0 ++ flags_return=0 ++ unset _flags_expr_ ++ return 0 + FLAGS_ARGC=0 + true + _flags_opt_=-- + _flags_arg_=f3 + _flags_type_=0 + _flags_name_= + case "${_flags_opt_}" in + shift + break + FLAGS_ARGV= + '[' 2 -gt 0 ']' + FLAGS_ARGV=''\''f3'\''' + shift + '[' 1 -gt 0 ']' + FLAGS_ARGV=''\''f3'\'' '\'''\''' + shift + '[' 0 -gt 0 ']' + unset _flags_arg_ _flags_len_ _flags_name_ _flags_opt_ _flags_pos_ _flags_strToEval_ _flags_type_ _flags_usName_ _flags_val_ + return 0 + flags_return=0 + '[' 0 -eq 2 ']' + return 0 + eval set -- ''\''f3'\'' '\'''\''' set -- 'f3' '' ++ set -- f3 '' + NAME=f3 + BRANCH=feature/f3 + gitflow_expand_nameprefix_arg_or_current + '[' f3 '!=' '' ']' + gitflow_expand_nameprefix_arg + local expanded_name exitcode + gitflow_require_name_arg + '[' f3 = '' ']' gitflow_resolve_nameprefix "$NAME" "$PREFIX" ++ gitflow_resolve_nameprefix f3 feature/ ++ local name prefix ++ local match matches num_matches ++ name=f3 ++ prefix=feature/ ++ git_local_branch_exists feature/f3 ++ '[' -n feature/f3 ']' git for-each-ref --format='%(refname:short)' refs/heads/$1 +++ git for-each-ref '--format=%(refname:short)' refs/heads/feature/f3 ++ '[' -n feature/f3 ']' ++ echo f3 ++ return 0 + expanded_name=f3 + exitcode=0 + case $exitcode in + NAME=f3 + BRANCH=feature/f3 + require_branch feature/f3 + git_branch_exists feature/f3 + '[' -n feature/f3 ']' + git_local_branch_exists feature/f3 + '[' -n feature/f3 ']' git for-each-ref --format='%(refname:short)' refs/heads/$1 ++ git for-each-ref '--format=%(refname:short)' refs/heads/feature/f3 + '[' -n feature/f3 ']' + flag keepremote + local FLAG + eval 'FLAG=$FLAGS_keepremote' FLAG=$FLAGS_keepremote ++ FLAG=1 + '[' 1 -eq 0 ']' + require_branch feature/f3 + git_branch_exists feature/f3 + '[' -n feature/f3 ']' + git_local_branch_exists feature/f3 + '[' -n feature/f3 ']' git for-each-ref --format='%(refname:short)' refs/heads/$1 ++ git for-each-ref '--format=%(refname:short)' refs/heads/feature/f3 + '[' -n feature/f3 ']' gitflow_config_get_base_branch $BRANCH ++ gitflow_config_get_base_branch feature/f3 ++ local branch ++ branch=feature/f3 git config --local --get "gitflow.branch.$branch.base" +++ git config --local --get gitflow.branch.feature/f3.base ++ echo develop + BASE_BRANCH=develop + BASE_BRANCH=develop + git_local_branch_exists develop + '[' -n develop ']' git for-each-ref --format='%(refname:short)' refs/heads/$1 ++ git for-each-ref '--format=%(refname:short)' refs/heads/develop + '[' -n develop ']' + '[' -f .git/.gitflow/MERGE_BASE ']' + git_is_clean_working_tree + git rev-parse --verify HEAD + git update-index -q --ignore-submodules --refresh file.txt: needs merge + git diff-files --quiet --ignore-submodules + return 1 + echo + echo 'Merge conflicts not resolved yet, use:' Merge conflicts not resolved yet, use: + echo ' git mergetool' git mergetool + echo ' git commit' git commit + echo + echo 'You can then complete the finish by running it again:' You can then complete the finish by running it again: + echo ' git flow feature finish f3' git flow feature finish f3 + echo + exit 1