+# 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 HEAD)
+ local remote_branch=$(git rev-parse "$branch")
+ local merge_base=$(git merge-base HEAD "$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
+}
+
+# shows the branch currently active in the repository.
+function show_active_branch()
+{
+#hmmm: if no args, assume current dir!?
+
+ for directory in "$@"; do
+ if [ $directory == "." ]; then
+ directory="$( \cd . && /bin/pwd )"
+#echo "calculated directory as '$directory'"
+ fi
+
+ echo -n -e "$(basename $directory) => branch "
+ pushd "$directory" &>/dev/null
+
+#hmmm: if git...
+ git rev-parse --abbrev-ref HEAD
+#hmmm: else OTHERS!!!
+
+ echo
+
+ popd &>/dev/null
+ done
+}
+
+# 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()