From 0f86a393ace984fcb2035138e01b61cda84af68d Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 2 Oct 2023 05:47:49 +0100 Subject: update/project/trees: optimise error handling some x_ calls are made that aren't needed. this is now corrected. additionally, some x_ calls were being made that are quite error-prone, like ones that use $PWD. Signed-off-by: Leah Rowe --- script/update/project/trees | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'script/update/project/trees') diff --git a/script/update/project/trees b/script/update/project/trees index f030c8dc..38d2c59d 100755 --- a/script/update/project/trees +++ b/script/update/project/trees @@ -29,7 +29,7 @@ main() for x in ${targets}; do x_ rm -f "${cfgsdir}/"*/seen - x_ download_for_target "${x}" + download_for_target "${x}" done } @@ -39,14 +39,14 @@ download_for_target() tree="undefined" rev="undefined" - x_ fetch_config "${_target}" + fetch_config "${_target}" if [ -d "${project}/${tree}" ]; then printf "REMARK: download/%s %s (%s): exists. Skipping.\n" \ "${project}" "${tree}" "${_target}" 1>&2 else - x_ fetch_from_upstream "${project}" - x_ prepare_new_tree "${_target}" "${tree}" "${rev}" + fetch_from_upstream + prepare_new_tree fi } @@ -87,20 +87,16 @@ check_config_for_target() fetch_from_upstream() { - [ -d "${1}" ] || mkdir -p "${1}" || return 1 - [ -d "${1}" ] || return 1 - [ -d "${1}/${1}" ] && return 0 + [ -d "${project}" ] || mkdir -p "${project}" || return 1 + [ -d "${project}" ] || return 1 + [ -d "${project}/${project}" ] && return 0 - ./update project repo ${1} || return 1 + x_ ./update project repo "${project}" } prepare_new_tree() { - target=${1} - tree=${2} - rev=${3} - - printf "Preparing %s tree %s (%s)\n" "${project}" "${tree}" "${target}" + printf "Creating %s tree %s (%s)\n" "${project}" "${tree}" "${_target}" x_ cp -R "${project}/${project}" "${project}/${tree}" x_ git_reset_rev "${project}/${tree}" "${rev}" "err" @@ -109,7 +105,7 @@ prepare_new_tree() git submodule update --init --checkout || \ err "prepare_new_tree ${project}/${tree}: can't update git modules" ) - x_ git_am_patches "${PWD}/${project}/${tree}" \ + git_am_patches "${PWD}/${project}/${tree}" \ "${PWD}/${cfgsdir}/${tree}/patches" "err" } -- cgit v1.2.1