From 6a882a8ad38a67a6b2d2c29f1071addda2e5f4dd Mon Sep 17 00:00:00 2001 From: Alex Malinovich Date: Sat, 10 Mar 2018 14:07:03 -0800 Subject: [PATCH] Stay on current branch unless BRANCHNAME is set --- plexupdate.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index 5b77b76..fdea524 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -228,8 +228,9 @@ if [ "${AUTOUPDATE}" = "yes" ]; then elif ! git diff --quiet; then warn "You have made changes to the plexupdate files, cannot auto update" else - BRANCHNAME="${BRANCHNAME:-master}" - if [ "${BRANCHNAME}" != "$(git symbolic-ref -q --short HEAD)" ]; then + if [ -z "${BRANCHNAME}" ]; then + BRANCHNAME="$(git symbolic-ref -q --short HEAD)" + elif [ "${BRANCHNAME}" != "$(git symbolic-ref -q --short HEAD)" ]; then git checkout "${BRANCHNAME}" fi # Force FETCH_HEAD to point to the correct branch (for older versions of git which don't default to current branch)