Skip to content

Commit

Permalink
Rewrite the way git-flow initialized its variables in git-flow and as…
Browse files Browse the repository at this point in the history
…sumed

existence of a valid git repo. Instead, functions gitflow_load_settings()
and gitflow_require_git_repo() have been added that can be called in each
submodule that requires such.

Specifically, git-flow init does NOT use this.
  • Loading branch information
nvie committed Feb 20, 2010
1 parent 21c7aa9 commit d72e4ac
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
9 changes: 0 additions & 9 deletions git-flow
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ if [ "$DEBUG" = "yes" ]; then
fi

export GITFLOW_DIR=$(dirname "$0")
export GIT_DIR=$(git rev-parse --git-dir)
export MASTER_BRANCH=$(git config --get gitflow.branch.master || echo master)
export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop || echo develop)
export ORIGIN=$(git config --get gitflow.origin || echo origin)
export README=$(git config --get gitflow.readme || echo README)

usage() {
echo "usage: git flow <subcommand>"
Expand Down Expand Up @@ -62,10 +57,6 @@ main() {
exit 1
fi

if ! git rev-parse --git-dir >/dev/null; then
die "Not a git repository"
fi

# run command
. "$GITFLOW_DIR/git-flow-$SUBCOMMAND"
FLAGS_PARENT="git flow $SUBCOMMAND"
Expand Down
2 changes: 2 additions & 0 deletions git-flow-feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Copyright (c) 2010 by Benedikt Böhm
#

gitflow_require_git_repo
gitflow_load_settings
PREFIX=$(git config --get gitflow.prefix.feature || echo feature/)

usage() {
Expand Down
2 changes: 2 additions & 0 deletions git-flow-hotfix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Copyright (c) 2010 by Benedikt Böhm
#

gitflow_require_git_repo
gitflow_load_settings
VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/)

Expand Down
2 changes: 2 additions & 0 deletions git-flow-release
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Copyright (c) 2010 by Benedikt Böhm
#

gitflow_require_git_repo
gitflow_load_settings
VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
PREFIX=$(git config --get gitflow.prefix.release || echo release/)

Expand Down
2 changes: 2 additions & 0 deletions git-flow-support
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Copyright (c) 2010 by Benedikt Böhm
#

gitflow_require_git_repo
gitflow_load_settings
VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
PREFIX=$(git config --get gitflow.prefix.support || echo support/)

Expand Down
15 changes: 15 additions & 0 deletions gitflow-common
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ gitflow_remote_branches() { git branch -r | sed 's/^[* ] //'; }
gitflow_all_branches() { gitflow_local_branches; gitflow_remote_branches; }
gitflow_all_tags() { git tag; }

# loading settings that can be overridden using git config
gitflow_load_settings() {
export GIT_DIR=$(git rev-parse --git-dir >/dev/null 2>&1)
export MASTER_BRANCH=$(git config --get gitflow.branch.master || echo master)
export DEVELOP_BRANCH=$(git config --get gitflow.branch.develop || echo develop)
export ORIGIN=$(git config --get gitflow.origin || echo origin)
export README=$(git config --get gitflow.readme || echo README)
}

#
# resolve_nameprefix
#
Expand Down Expand Up @@ -107,6 +116,12 @@ gitflow_test_clean_working_tree() {
fi
}

gitflow_require_git_repo() {
if ! git rev-parse --git-dir >/dev/null 2>&1; then
die "Not a git repository"
fi
}

gitflow_require_clean_working_tree() {
gitflow_test_clean_working_tree
local result=$?
Expand Down

0 comments on commit d72e4ac

Please sign in to comment.