From 10e27b5c1723c1f7ca96649f5e9efc5721bdd3f2 Mon Sep 17 00:00:00 2001 From: RealStickman Date: Fri, 2 Sep 2022 15:49:00 +0200 Subject: [PATCH] Fix exit with error if master or main aren't found --- arch-config/scripts/in_path/sc-git-pull | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch-config/scripts/in_path/sc-git-pull b/arch-config/scripts/in_path/sc-git-pull index c968239b..6a4b84c2 100755 --- a/arch-config/scripts/in_path/sc-git-pull +++ b/arch-config/scripts/in_path/sc-git-pull @@ -17,15 +17,18 @@ for dir in "${dirs[@]}"; do # change into that directory cd "$dir" # try to check out master or main branch + set +e git checkout -q master 2>/dev/null \ || git checkout -q main 2>/dev/null # check whether the previous two commands failed if [ $? -ne 0 ]; then - printf "Couldn't find master or main branches\n" - exit 1 + printf "Couldn't find master or main branch\n" + # if all is well, fetch and pull + else + git fetch --all + git pull fi - git fetch --all - git pull + set -e done exit 0