Skip to content
Browse files

Rewrite the way git-flow initialized its variables in git-flow and as…

…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...
1 parent 21c7aa9 commit d72e4aceed207a90dbc7215c1738120bb844e21c @nvie committed Feb 16, 2010
Showing with 23 additions and 9 deletions.
  1. +0 −9 git-flow
  2. +2 −0 git-flow-feature
  3. +2 −0 git-flow-hotfix
  4. +2 −0 git-flow-release
  5. +2 −0 git-flow-support
  6. +15 −0 gitflow-common
View
9 git-flow
@@ -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>"
@@ -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"
View
2 git-flow-feature
@@ -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() {
View
2 git-flow-hotfix
@@ -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/)
View
2 git-flow-release
@@ -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/)
View
2 git-flow-support
@@ -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/)
View
15 gitflow-common
@@ -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
#
@@ -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=$?

0 comments on commit d72e4ac

Please sign in to comment.
Something went wrong with that request. Please try again.