From b85df7f323252b21cf3292288aed4bb517e1f80b Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Sun, 8 May 2022 14:47:57 -0400 Subject: [PATCH] cleanup and review fix-remotes --- fix-remotes.sh | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/fix-remotes.sh b/fix-remotes.sh index c35304b..dd28fcc 100755 --- a/fix-remotes.sh +++ b/fix-remotes.sh @@ -4,6 +4,8 @@ FSL_GIT="ssh://git.fsl.cs.sunysb.edu/scm/git" KORG_GIT="git://git.kernel.org/pub/scm/linux/kernel/git" +DEBUG="yes" # set to "no" to turn off debug + # function to execute commands runcmd() { echo "CMD: $@" @@ -29,9 +31,10 @@ fi if test -z "$1"; then THIS_REPO=`basename $PWD | sed -e 's/^wrapfs-//' -e 's/\.y$//'` else - THIS_REPO="$1" + THIS_REPO="$1" # this is how you can "force" a wrapfs-latest clone + # to rebase to a stable kernel say, wrapfs-5.18 fi -#echo THIS_REPO:$THIS_REPO +test "$DEBUG" eq "yes" && echo THIS_REPO:$THIS_REPO case "$THIS_REPO" in 2.6.* | 3.* | 4.* | 5.* | latest ) ;; * ) echo This repo is unknown: $THIS_REPO @@ -39,17 +42,17 @@ case "$THIS_REPO" in ;; esac -# find out the URL for the remote "origin"` +# 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 THIS_ORIGIN_URL=`git config --get remote.origin.url 2>/dev/null` -#echo THIS_ORIGIN_URL=$THIS_ORIGIN_URL -# expected origin URL +test "$DEBUG" eq "yes" && echo THIS_ORIGIN_URL=$THIS_ORIGIN_URL +# expected origin URL (for FSL git server) case "$THIS_REPO" in latest ) EXPECTED_ORIGIN_URL="$FSL_GIT/wrapfs-${THIS_REPO}.git" ;; * ) EXPECTED_ORIGIN_URL="$FSL_GIT/wrapfs-${THIS_REPO}.y.git" ;; esac -#echo EXPECTED_ORIGIN_URL=$EXPECTED_ORIGIN_URL +test "$DEBUG" eq "yes" && echo EXPECTED_ORIGIN_URL=$EXPECTED_ORIGIN_URL # set new remote URL as needed if test "$THIS_ORIGIN_URL" != "$EXPECTED_ORIGIN_URL" ; then @@ -62,9 +65,9 @@ if test "$THIS_ORIGIN_URL" != "$EXPECTED_ORIGIN_URL" ; then fi fi -# find out the URL for the remote "korg"` +# find out the URL for the remote "korg" THIS_KORG_URL=`git config --get remote.korg.url 2>/dev/null` -#echo THIS_KORG_URL=$THIS_KORG_URL +test "$DEBUG" eq "yes" && echo THIS_KORG_URL=$THIS_KORG_URL # expected korg URL case "$THIS_REPO" in latest ) @@ -76,7 +79,7 @@ case "$THIS_REPO" in KORG_BRANCH="linux-${THIS_REPO}.y" ;; esac -#echo EXPECTED_KORG_URL=$EXPECTED_KORG_URL +test "$DEBUG" eq "yes" && echo EXPECTED_KORG_URL=$EXPECTED_KORG_URL # set new remote URL as needed if test "$THIS_KORG_URL" != "$EXPECTED_KORG_URL" ; then @@ -91,18 +94,20 @@ 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/]+"` +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 + if git branch | grep -qP "^\*? +wrapfs$" ; then runcmd git branch -u origin/wrapfs wrapfs else runcmd git checkout -b wrapfs origin/wrapfs fi fi +# Check if there are any other unknown branches EXP_BR="origin/master|origin/wrapfs|origin/guilt/wrapfs|korg/$KORG_BRANCH" -BRANCHES=`git branch -r|grep -vP $EXP_BR` -if [[ -n $BRANCHES ]]; then +BRANCHES=`git branch -r | grep -vP $EXP_BR` +if test -n "$BRANCHES" ; then echo -e "$0: Found Unexpected Remote Branches:" - echo "$BRANCHES"|xargs + echo "$BRANCHES" + exit 1 fi -- 2.34.1