;;
esac
-# we could verify we have both master and wrapfs branches
-# as done below but I don't really see the purpose of this because
-# we are going to overwrite/add the origin and korg remote URL's anyway
-# so doing this gives us no actionable information. I feel like it just
-# confuses the user with what looks like an error but is actually something the
-# script is about to fix.
-#TMP_BR_LIST=/tmp/.tbr.$$
-#(
-#cat <<EOF
-# origin/HEAD -> origin/master
-# origin/guilt/wrapfs
-# origin/master
-# origin/wrapfs
-#EOF
-#) > $TMP_BR_LIST
-#EXP_BR_LIST=/tmp/.ebr.$$
-#git branch -r > $EXP_BR_LIST
-#if ! cmp $TMP_BR_LIST $EXP_BR_LIST &>/dev/null; then
-# echo "Expected list of branches mismatched for `basename $PWD`"
-# diff -u $TMP_BR_LIST $EXP_BR_LIST
-# /bin/rm -f $TMP_BR_LIST $EXP_BR_LIST
-## exit 1
-#fi
-#/bin/rm -f $TMP_BR_LIST $EXP_BR_LIST
-
# find out the URL for the remote "origin"`
# `git remote get-url origin` is the newest syntax but the syntax below
# works on newer and older versions of git
-# so I'm not sure which is preferable
THIS_ORIGIN_URL=`git config --get remote.origin.url 2>/dev/null`
#echo THIS_ORIGIN_URL=$THIS_ORIGIN_URL
# expected origin URL
runcmd git remote set-url korg $EXPECTED_KORG_URL
fi
fi
+
+# grep out the upstream branch for wrapfs
+# and set upstream to origin/wrapfs if it isn't already
+WRAPFS_UPSTREAM=`git branch -vv|grep -oP "\*? +wrapfs\s+[0-9a-f]+ \[\K[a-z/]+"`
+if test "$WRAPFS_UPSTREAM" != "origin/wrapfs"; then
+ if git branch | grep -qP "^\*? +wrapfs$"; then
+ runcmd git branch -u origin/wrapfs wrapfs
+ else
+ runcmd git checkout -b wrapfs origin/wrapfs
+ fi
+fi
+
+EXP_BR="origin/master|origin/wrapfs|origin/guilt/wrapfs|korg/$KORG_BRANCH"
+BRANCHES=`git branch -r|grep -vP $EXP_BR`
+if [[ -n $BRANCHES ]]; then
+ echo -e "$0: Found Unexpected Remote Branches:"
+ echo "$BRANCHES"|xargs
+fi