Quote all variables in function/program arguments.
diff --git a/git-flow-feature b/git-flow-feature
index 2e99eb3..db45d81 100644
--- a/git-flow-feature
+++ b/git-flow-feature
@@ -148,17 +148,17 @@
if noflag force; then
gitflow_require_clean_working_tree
fi
- gitflow_require_branch_absent $BRANCH
+ gitflow_require_branch_absent "$BRANCH"
# update the local repo with remote changes, if asked
if flag fetch; then
- git fetch -q $ORIGIN $DEVELOP_BRANCH
+ git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
fi
- gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
+ gitflow_require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
# create branch
- if ! git checkout -b $BRANCH $BASE; then
+ if ! git checkout -b "$BRANCH" "$BASE"; then
die "Could not create feature branch '$BRANCH'"
fi
@@ -181,7 +181,7 @@
expand_nameprefix_arg
# sanity checks
- gitflow_require_branch $BRANCH
+ gitflow_require_branch "$BRANCH"
# detect if we're restoring from a merge conflict
if [ -f "$GIT_DIR/.gitflow/MERGE_BASE" ]; then
@@ -200,7 +200,7 @@
# Since the working tree is now clean, either the user did a
# succesfull merge manually, or the merge was cancelled.
# We detect this using gitflow_is_branch_merged_into()
- if gitflow_is_branch_merged_into $BRANCH $FINISH_BASE; then
+ if gitflow_is_branch_merged_into "$BRANCH" "$FINISH_BASE"; then
rm -f "$GIT_DIR/.gitflow/MERGE_BASE"
helper_finish_cleanup
exit 0
@@ -228,13 +228,13 @@
# update local repo with remote changes first, if asked
if flag fetch; then
- git fetch -q $ORIGIN $BRANCH
+ git fetch -q "$ORIGIN" "$BRANCH"
fi
- if has $ORIGIN/$BRANCH $REMOTE_BRANCHES; then
- gitflow_require_branches_equal $BRANCH $ORIGIN/$BRANCH
+ if has "$ORIGIN/$BRANCH" "$REMOTE_BRANCHES"; then
+ gitflow_require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH"
fi
- gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
+ gitflow_require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
# if the user wants to rebase, do that first
if flag rebase; then
@@ -248,11 +248,11 @@
fi
# merge into BASE
- git checkout $DEVELOP_BRANCH
- if [ "$(git rev-list -n2 $DEVELOP_BRANCH..$BRANCH | wc -l)" -eq 1 ]; then
- git merge --ff $BRANCH
+ git checkout "$DEVELOP_BRANCH"
+ if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
+ git merge --ff "$BRANCH"
else
- git merge --no-ff $BRANCH
+ git merge --no-ff "$BRANCH"
fi
if [ $? -ne 0 ]; then
@@ -277,14 +277,14 @@
helper_finish_cleanup() {
# sanity checks
- gitflow_require_branch $BRANCH
+ gitflow_require_branch "$BRANCH"
gitflow_require_clean_working_tree
# delete branch
if flag fetch; then
- git push $ORIGIN :refs/heads/$BRANCH
+ git push "$ORIGIN" ":refs/heads/$BRANCH"
fi
- git branch -d $BRANCH
+ git branch -d "$BRANCH"
echo
echo "Summary of actions:"
@@ -301,18 +301,18 @@
# sanity checks
gitflow_require_clean_working_tree
- gitflow_require_branch $BRANCH
- git fetch -q $ORIGIN
- gitflow_require_branch_absent $ORIGIN/$BRANCH
+ gitflow_require_branch "$BRANCH"
+ git fetch -q "$ORIGIN"
+ gitflow_require_branch_absent "$ORIGIN/$BRANCH"
# create remote branch
- git push $ORIGIN $BRANCH:refs/heads/$BRANCH
- git fetch -q $ORIGIN
+ git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
+ git fetch -q "$ORIGIN"
# configure remote tracking
- git config branch.$BRANCH.remote $ORIGIN
- git config branch.$BRANCH.merge refs/heads/$BRANCH
- git checkout $BRANCH
+ git config "branch.$BRANCH.remote" "$ORIGIN"
+ git config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
+ git checkout "$BRANCH"
echo
echo "Summary of actions:"
@@ -328,12 +328,12 @@
# sanity checks
gitflow_require_clean_working_tree
- gitflow_require_branch_absent $BRANCH
- git fetch -q $ORIGIN
- gitflow_require_branch $ORIGIN/$BRANCH
+ gitflow_require_branch_absent "$BRANCH"
+ git fetch -q "$ORIGIN"
+ gitflow_require_branch "$ORIGIN/$BRANCH"
# create tracking branch
- git checkout -b $BRANCH $ORIGIN/$BRANCH
+ git checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
echo
echo "Summary of actions:"
@@ -347,15 +347,15 @@
if [ "$NAME" != "" ]; then
expand_nameprefix_arg
- BASE=$(git merge-base $DEVELOP_BRANCH $BRANCH)
- git diff $BASE..$BRANCH
+ BASE=$(git merge-base "$DEVELOP_BRANCH" "$BRANCH")
+ git diff "$BASE..$BRANCH"
else
if ! gitflow_current_branch | grep -q "^$PREFIX"; then
die "Not on a feature branch. Name one explicitly."
fi
- BASE=$(git merge-base $DEVELOP_BRANCH HEAD)
- git diff $BASE
+ BASE=$(git merge-base "$DEVELOP_BRANCH" HEAD)
+ git diff "$BASE"
fi
}
diff --git a/git-flow-hotfix b/git-flow-hotfix
index b8d4214..e7ff5e2 100644
--- a/git-flow-hotfix
+++ b/git-flow-hotfix
@@ -65,12 +65,12 @@
if [ "$branch_sha" = "$master_sha" ]; then
printf "(no commits yet)"
else
- typeset tagname=$(git name-rev --tags --no-undefined --name-only $base)
+ typeset tagname=$(git name-rev --tags --no-undefined --name-only "$base")
typeset nicename
if [ "$tagname" != "" ]; then
nicename=$tagname
else
- nicename=$(git rev-parse --short $base)
+ nicename=$(git rev-parse --short "$base")
fi
printf "(based on $nicename)"
fi
@@ -121,15 +121,15 @@
# sanity checks
gitflow_require_clean_working_tree
- gitflow_require_branch_absent $BRANCH
- gitflow_require_tag_absent $VERSION_PREFIX$VERSION
+ gitflow_require_branch_absent "$BRANCH"
+ gitflow_require_tag_absent "$VERSION_PREFIX$VERSION"
if flag fetch; then
- git fetch -q $ORIGIN $MASTER_BRANCH
+ git fetch -q "$ORIGIN" "$MASTER_BRANCH"
fi
- gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
+ gitflow_require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
# create branch
- git checkout -b $BRANCH $BASE
+ git checkout -b "$BRANCH" "$BASE"
echo
echo "Summary of actions:"
@@ -159,24 +159,24 @@
fi
# sanity checks
- gitflow_require_branch $BRANCH
+ gitflow_require_branch "$BRANCH"
gitflow_require_clean_working_tree
if flag fetch; then
- git fetch -q $ORIGIN $MASTER_BRANCH || \
+ git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not fetch $MASTER_BRANCH from $ORIGIN."
- git fetch -q $ORIGIN $DEVELOP_BRANCH || \
+ git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not fetch $DEVELOP_BRANCH from $ORIGIN."
fi
- gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
- gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
+ gitflow_require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
+ gitflow_require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
# try to merge into master
# in case a previous attempt to finish this release branch has failed,
# but the merge into master was successful, we skip it now
- if ! gitflow_is_branch_merged_into $BRANCH $MASTER_BRANCH; then
- git checkout $MASTER_BRANCH || \
+ if ! gitflow_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
+ git checkout "$MASTER_BRANCH" || \
die "Could not check out $MASTER_BRANCH."
- git merge --no-ff $BRANCH || \
+ git merge --no-ff "$BRANCH" || \
die "There were merge conflicts."
# TODO: What do we do now?
fi
@@ -185,7 +185,7 @@
# in case a previous attempt to finish this release branch has failed,
# but the tag was set successful, we skip it now
typeset tagname=$VERSION_PREFIX$VERSION
- if ! gitflow_tag_exists $tagname; then
+ if ! gitflow_tag_exists "$tagname"; then
typeset opts="-a"
flag sign && opts="$opts -s"
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
@@ -197,19 +197,19 @@
# try to merge into develop
# in case a previous attempt to finish this release branch has failed,
# but the merge into develop was successful, we skip it now
- if ! gitflow_is_branch_merged_into $BRANCH $DEVELOP_BRANCH; then
- git checkout $DEVELOP_BRANCH || \
+ if ! gitflow_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
+ git checkout "$DEVELOP_BRANCH" || \
die "Could not check out $DEVELOP_BRANCH."
# TODO: Actually, accounting for 'git describe' pays, so we should
# ideally git merge --no-ff $tagname here, instead!
- git merge --no-ff $BRANCH || \
+ git merge --no-ff "$BRANCH" || \
die "There were merge conflicts."
# TODO: What do we do now?
fi
# delete branch
- git branch -d $BRANCH
+ git branch -d "$BRANCH"
# TODO: Implement an optional push to master
# git push origin develop; git push origin master; git push --tags origin
diff --git a/git-flow-init b/git-flow-init
index c2e75b2..a8e0825 100644
--- a/git-flow-init
+++ b/git-flow-init
@@ -27,47 +27,47 @@
fi
if ! git rev-parse --quiet --verify HEAD 2>&1 >/dev/null; then
- touch $README
- git add $README
+ touch "$README"
+ git add "$README"
git commit --quiet -m "initial commit"
if [ "$MASTER_BRANCH" != "master" ]; then
- git branch -m master $MASTER_BRANCH
+ git branch -m master "$MASTER_BRANCH"
fi
echo "- An initial commit was created at branch '$MASTER_BRANCH'"
fi
- if ! git rev-parse --verify $MASTER_BRANCH 2>&1 >/dev/null; then
+ if ! git rev-parse --verify "$MASTER_BRANCH" 2>&1 >/dev/null; then
die "Cannot find your master branch. Try: git branch -m <mymaster> $MASTER_BRANCH"
fi
gitflow_require_clean_working_tree
- if git remote | grep -q $ORIGIN; then
- git fetch -q $ORIGIN
- gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
+ if git remote | grep -q "$ORIGIN"; then
+ git fetch -q "$ORIGIN"
+ gitflow_require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
fi
- if git rev-parse --verify $DEVELOP_BRANCH 2>&1 >/dev/null; then
- gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
+ if git rev-parse --verify "$DEVELOP_BRANCH" 2>&1 >/dev/null; then
+ gitflow_require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
else
- git checkout -q -b $DEVELOP_BRANCH $MASTER_BRANCH
+ git checkout -q -b "$DEVELOP_BRANCH" "$MASTER_BRANCH"
echo "- A new branch '$DEVELOP_BRANCH' was created"
echo "- You are now on branch '$DEVELOP_BRANCH'"
fi
- if ! git remote | grep -q $ORIGIN; then
+ if ! git remote | grep -q "$ORIGIN"; then
if [ "$1" = "" ]; then
echo "- No remote location was added. Try: git remote add $ORIGIN <url>"
else
- git remote add $ORIGIN $1
+ git remote add "$ORIGIN" "$1"
echo "- A new remote location '$1' was added"
fi
fi
echo
- if git remote | grep -q $ORIGIN; then
- git push $ORIGIN $MASTER_BRANCH $DEVELOP_BRANCH
+ if git remote | grep -q "$ORIGIN"; then
+ git push "$ORIGIN" "$MASTER_BRANCH" "$DEVELOP_BRANCH"
fi
}
diff --git a/git-flow-release b/git-flow-release
index 9da454b..95c695d 100644
--- a/git-flow-release
+++ b/git-flow-release
@@ -77,7 +77,7 @@
if [ "$branch_sha" = "$develop_sha" ]; then
printf "(no commits yet)"
else
- typeset nicename=$(git rev-parse --short $base)
+ typeset nicename=$(git rev-parse --short "$base")
printf "(based on $nicename)"
fi
else
@@ -127,15 +127,15 @@
# sanity checks
gitflow_require_clean_working_tree
- gitflow_require_branch_absent $BRANCH
- gitflow_require_tag_absent $VERSION_PREFIX$VERSION
+ gitflow_require_branch_absent "$BRANCH"
+ gitflow_require_tag_absent "$VERSION_PREFIX$VERSION"
if flag fetch; then
- git fetch -q $ORIGIN $DEVELOP_BRANCH
+ git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
fi
- gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
+ gitflow_require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
# create branch
- git checkout -b $BRANCH $BASE
+ git checkout -b "$BRANCH" "$BASE"
echo
echo "Summary of actions:"
@@ -165,24 +165,24 @@
fi
# sanity checks
- gitflow_require_branch $BRANCH
+ gitflow_require_branch "$BRANCH"
gitflow_require_clean_working_tree
if flag fetch; then
- git fetch -q $ORIGIN $MASTER_BRANCH || \
+ git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not fetch $MASTER_BRANCH from $ORIGIN."
- git fetch -q $ORIGIN $DEVELOP_BRANCH || \
+ git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not fetch $DEVELOP_BRANCH from $ORIGIN."
fi
- gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
- gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
+ gitflow_require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
+ gitflow_require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
# try to merge into master
# in case a previous attempt to finish this release branch has failed,
# but the merge into master was successful, we skip it now
- if ! gitflow_is_branch_merged_into $BRANCH $MASTER_BRANCH; then
- git checkout $MASTER_BRANCH || \
+ if ! gitflow_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
+ git checkout "$MASTER_BRANCH" || \
die "Could not check out $MASTER_BRANCH."
- git merge --no-ff $BRANCH || \
+ git merge --no-ff "$BRANCH" || \
die "There were merge conflicts."
# TODO: What do we do now?
fi
@@ -191,7 +191,7 @@
# in case a previous attempt to finish this release branch has failed,
# but the tag was set successful, we skip it now
typeset tagname=$VERSION_PREFIX$VERSION
- if ! gitflow_tag_exists $tagname; then
+ if ! gitflow_tag_exists "$tagname"; then
typeset opts="-a"
flag sign && opts="$opts -s"
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
@@ -203,19 +203,19 @@
# try to merge into develop
# in case a previous attempt to finish this release branch has failed,
# but the merge into develop was successful, we skip it now
- if ! gitflow_is_branch_merged_into $BRANCH $DEVELOP_BRANCH; then
- git checkout $DEVELOP_BRANCH || \
+ if ! gitflow_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
+ git checkout "$DEVELOP_BRANCH" || \
die "Could not check out $DEVELOP_BRANCH."
# TODO: Actually, accounting for 'git describe' pays, so we should
# ideally git merge --no-ff $tagname here, instead!
- git merge --no-ff $BRANCH || \
+ git merge --no-ff "$BRANCH" || \
die "There were merge conflicts."
# TODO: What do we do now?
fi
# delete branch
- git branch -d $BRANCH
+ git branch -d "$BRANCH"
# TODO: Implement an optional push to master
# git push origin develop; git push origin master; git push --tags origin
diff --git a/git-flow-support b/git-flow-support
index 07c9ed2..1f5918f 100644
--- a/git-flow-support
+++ b/git-flow-support
@@ -67,12 +67,12 @@
if [ "$branch_sha" = "$master_sha" ]; then
printf "(no commits yet)"
else
- typeset tagname=$(git name-rev --tags --no-undefined --name-only $base)
+ typeset tagname=$(git name-rev --tags --no-undefined --name-only "$base")
typeset nicename
if [ "$tagname" != "" ]; then
nicename=$tagname
else
- nicename=$(git rev-parse --short $base)
+ nicename=$(git rev-parse --short "$base")
fi
printf "(based on $nicename)"
fi
@@ -135,9 +135,9 @@
# fetch remote changes
if flag fetch; then
- git fetch -q $ORIGIN $BASE
+ git fetch -q "$ORIGIN" "$BASE"
fi
- gitflow_require_branch_absent $BRANCH
+ gitflow_require_branch_absent "$BRANCH"
# create branch
git checkout -b "$BRANCH" "$BASE"