From: Stephen Rothwell Date: Wed, 7 Dec 2022 04:00:16 +0000 (+1100) Subject: fetch_trees: use new get_* functions X-Git-Url: https://git.ozlabs.org/?a=commitdiff_plain;h=3e94808d12b9b2acdcfef9fe72e7aeac34de66c1;p=next-scripts fetch_trees: use new get_* functions --- diff --git a/fetch_trees b/fetch_trees index f93d3d3..12d50d0 100755 --- a/fetch_trees +++ b/fetch_trees @@ -1,20 +1,13 @@ #!/bin/bash tools_dir=$(dirname "$0") -# shellcheck source=/dev/null . "$tools_dir/common.sh" '' if [ "$1" = '-n' ]; then shift - last=$(tail -n1 "$SHA1_FILE" | cut -f1 -d$'\t') - start_from=$(awk -F '\t' '/^[^#]/ && $3 == "'"$last"'" { - do - getline; - while (/^#/ || $2 == "branch"); - print $3; - exit 0; - }' "$CTRL_FILE") - if [ "X$last" = "X$start_from" ]; then + last=$(tail -n1 "$SHA1_FILE" | cut -f1 -d"$_TAB") + start_from=$(get_branches | sed -n '/^'"$last"'$/{n;p;}') + if [ -z "$start_from" ]; then exit 0 fi fi @@ -29,11 +22,6 @@ if [ "$1" = '-s' ]; then shift fi -get_field() -{ - awk -F '\t' '/^[^#]/ && $3 == "'"$1"'" { print $'"$2"'; }' "$CTRL_FILE" -} - fetch_git() { git fetch "$1" @@ -41,7 +29,7 @@ fetch_git() trees="$*" if ! [ "$trees" ]; then - trees=$(awk -F '\t' '/^[^#]/ && $2 != "branch" { print $3 }' "$CTRL_FILE") + trees=$(get_branches) fi for name in $trees; do @@ -53,7 +41,7 @@ for name in $trees; do fi fi - type=$(get_field "$name" 2) + type=$(get_type "$name") if ! [ "$type" ]; then printf '%s: unknown tree\n' "$name" 1>&2 continue @@ -63,7 +51,7 @@ for name in $trees; do fun="fetch_$type" tfun=$(type -t "$fun") if [ "$tfun" = 'function' ]; then - branch=$(get_field "$name" 5) + branch=$(get_remote_branch "$name") old_sha=$(git rev-parse "$name/$branch") "$fun" "$name" new_sha=$(git rev-parse "$name/$branch")