Fix: Work around bash ignoring errors in function

when function itself has error checking

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-03-13 14:39:30 +01:00
parent 1a8bcc58a4
commit 17222ae1ae
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

View file

@ -70,22 +70,22 @@ function run_restore() {
fi fi
info "Initializing empty git repository..." info "Initializing empty git repository..."
git init -b ${BRANCH} git init -b ${BRANCH} || fatal "Initializing repo failed (exit $?)"
info "Setting up remote..." info "Setting up remote..."
git remote add origin "${REMOTE}" git remote add origin "${REMOTE}" || fatal "Adding remote failed (exit $?)"
info "Fetching remote to reset..." info "Fetching remote to reset..."
git fetch origin ${BRANCH} || { git fetch origin ${BRANCH} || fatal "Fetch failed (exit $?)"
error "Fetch failed (exit $?)"
return 1
}
info "Resetting to remote state..." info "Resetting to remote state..."
git reset --hard FETCH_HEAD git reset --hard FETCH_HEAD || fatal "Resetting onto FETCH_HEAD failed (exit $?)"
git branch -u origin/"${BRANCH}" "${BRANCH}" git branch -u origin/"${BRANCH}" "${BRANCH}" || fatal "Configuring upstream branch failed (exit $?)"
[[ -z $CHOWN_UID ]] || chown -R ${CHOWN_UID}:${CHOWN_GID} . [[ -z $CHOWN_UID ]] || {
info "Chown-ing files to ${CHOWN_UID}:${CHOWN_GID}..."
chown -R ${CHOWN_UID}:${CHOWN_GID} . || fatal "Chown failed (exit $?)"
}
} }
function run_sync() { function run_sync() {