From 9ede6ab548f8d838807514730b715772506150aa Mon Sep 17 00:00:00 2001 From: Alex Malinovich Date: Wed, 22 Apr 2020 15:14:42 -0400 Subject: [PATCH] Fix branchname switching errors --- plexupdate.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index 0999a7a..679ab9c 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -233,13 +233,15 @@ if [ "${AUTOUPDATE}" = "yes" ]; then else 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) if git fetch origin ${BRANCHNAME} --quiet && ! git diff --quiet FETCH_HEAD; then info "Auto-updating..." + if [ "${BRANCHNAME}" != "$(git symbolic-ref -q --short HEAD)" ]; then + git checkout "${BRANCHNAME}" + fi + # Use an associative array to store permissions. If you're running bash < 4, the declare will fail and we'll # just run in "dumb" mode without trying to restore permissions declare -A FILE_OWNER FILE_PERMS && \