From cbd18a49ae2cd270600bac198c4c407e9346b436 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Tue, 20 Aug 2024 15:53:28 +0300 Subject: [PATCH] Refactor(update-remotes): `set -e` instead of chaining commands with `&&` --- update-remotes | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/update-remotes b/update-remotes index 354fdb4..02ac77a 100755 --- a/update-remotes +++ b/update-remotes @@ -1,7 +1,8 @@ #! /bin/sh +set -e -current="`git config --get --path remote.current.url`" -origin="`git config --get --path remote.origin.url`" +current="`git config --get --path remote.current.url`" || : +origin="`git config --get --path remote.origin.url`" || : branches="master ${1:+$@}" if [ -n "$origin" ]; then @@ -9,7 +10,7 @@ if [ -n "$origin" ]; then echo "Config error (both origin and current)" >&2 exit 1 else - cd "$origin" && + cd "$origin" exec ./update-remotes "$@" fi elif [ -z "$current" ]; then @@ -17,15 +18,15 @@ elif [ -z "$current" ]; then exit 1 fi -git fetch current && -{ git pull --ff-only current master || git reset --hard current/master ; } && -git set-date && +git fetch current +{ git pull --ff-only current master || git reset --hard current/master ; } +git set-date -web="`git config --get --path remote.web.url`" && +web="`git config --get --path remote.web.url`" if [ -n "$web" ]; then git push --force web $branches -fi && +fi -cd "$current" && -git pull origin && +cd "$current" +git pull origin exec git set-date -- 2.39.5