]> git.ozlabs.org Git - next-scripts/commitdiff
fetch_trees: use new get_* functions
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 7 Dec 2022 04:00:16 +0000 (15:00 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 7 Dec 2022 04:00:16 +0000 (15:00 +1100)
fetch_trees

index f93d3d3a00d94fd639a32210676a18f27bcfd3ca..12d50d03478275c5b911c0f8283e17ea0078f4dc 100755 (executable)
@@ -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")