From c447d7eb9dd5d20d185a7e9fefccdce8dc0b9cc4 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 19 Apr 2024 09:49:21 -0300 Subject: [PATCH] Handle 'git checkout' error gracefully --- libexec/portzap/portzap-pull | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libexec/portzap/portzap-pull b/libexec/portzap/portzap-pull index 585c936..63fccd9 100755 --- a/libexec/portzap/portzap-pull +++ b/libexec/portzap/portzap-pull @@ -19,9 +19,13 @@ change_branch() branch=$2 echo "[-] Attempt to change branch: ${branch}" doas -u _portzap "${git}" fetch "${remote}" > /dev/null 2>&1 - doas -u _portzap "${git}" checkout "${branch}" > /dev/null 2>&1 || - doas -u _portzap "${git}" checkout -t "${remote}"/"${branch}" > /dev/null 2>&1 - echo "[-] Done" + if ! doas -u _portzap "${git}" checkout "${branch}" > /dev/null 2>&1 || + doas -u _portzap "${git}" checkout -t "${remote}"/"${branch}" > /dev/null 2>&1; then + echo "[-] 'git checkout' exited with an error" + exit 1 + else + echo "[-] Done" + fi set -e }