Rewrite the way git-flow initialized its variables in git-flow and assumed
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.
diff --git a/git-flow b/git-flow
index 7f8c90c..84adc05 100755
--- a/git-flow
+++ b/git-flow
@@ -19,11 +19,6 @@
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 @@
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"
diff --git a/git-flow-feature b/git-flow-feature
index af1041d..8d335c3 100644
--- a/git-flow-feature
+++ b/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() {
diff --git a/git-flow-hotfix b/git-flow-hotfix
index 9bfd058..357eb78 100644
--- a/git-flow-hotfix
+++ b/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/)
diff --git a/git-flow-release b/git-flow-release
index e936de2..38e1790 100644
--- a/git-flow-release
+++ b/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/)
diff --git a/git-flow-support b/git-flow-support
index 99baf37..1bdbaed 100644
--- a/git-flow-support
+++ b/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/)
diff --git a/gitflow-common b/gitflow-common
index 93f1e7a..2ff3036 100644
--- a/gitflow-common
+++ b/gitflow-common
@@ -44,6 +44,15 @@
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 @@
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=$?