+##function parent_branch_name()
+##{
+ ##echo "$(git branch -vv | grep \* | cut -d ' ' -f2)"
+##}
+
+# reports the status of the branch by echoing one of these values:
+# okay: up to date and everything is good.
+# needs_pull: this branch needs to be pulled from origins.
+# needs_push: there are unsaved changes on this branch to push to remote store.
+# diverged: the branches diverged and are going to need a merge.
+# reference: https://stackoverflow.com/questions/3258243/check-if-pull-needed-in-git
+function check_branch_state()
+{
+ local branch="$1"; shift
+
+ if [ -z "$branch" ]; then
+ echo "No branch was passed to check branch state."
+ return 1
+ fi
+
+ local to_return=120 # unknown issue.
+
+ local local_branch=$(git rev-parse @)
+ local remote_branch=$(git rev-parse "$branch")
+ local merge_base=$(git merge-base @ "$branch")
+
+ local to_echo=
+ if [ "$local_branch" == "$remote_branch" ]; then
+ to_echo="okay"
+ elif [ "$local_branch" == "$merge_base" ]; then
+ to_echo="needs_pull"
+ elif [ "$remote_branch" == "$merge_base" ]; then
+ to_echo="needs_push"
+ else
+ to_echo="diverged"
+ fi
+
+ echo -n "$to_echo"
+
+ return $to_return
+}
+
+# only shows the branch state if it's not okay.
+# note that this is not the same as a conditional branch (ha ha).
+function show_branch_conditionally()