]> git.ozlabs.org Git - next-scripts/commitdiff
fetch_trees: skip comments and branch control lines just using awk
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 6 Jun 2018 01:32:53 +0000 (11:32 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 6 Jun 2018 01:32:53 +0000 (11:32 +1000)
fetch_trees

index b15e35baf0f656863352d7ce5e8cf9c9002f1300..87e1b6cca2ab0af600b4f83b07af0f4dece748a8 100755 (executable)
@@ -5,7 +5,7 @@
 [ "$1" = "-n" ] && {
        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)
+       start_from=$(awk -F '\t' '/^[^#]/ && $3 == "'$last'" { do getline; while (/^#/ || $2 == "branch"); print $3; exit 0; }' $CTRL_FILE)
 }
 
 [ "$1" = "-s" ] && {
@@ -20,8 +20,7 @@
 
 get_field()
 {
-       grep -v '^#' $CTRL_FILE |
-               awk -F '\t' '$3 == "'$1'" { print $'$2'; }'
+       awk -F '\t' '/^[^#]/ && $3 == "'$1'" { print $'$2'; }' $CTRL_FILE
 }
 
 fetch_git()
@@ -97,7 +96,7 @@ fetch_quilt()
 
 trees="$@"
 [ "$trees" ] ||
-       trees=$(grep -v '^#' $CTRL_FILE | awk -F '\t' '{ print $3 }')
+       trees=$(awk -F '\t' '/^[^#]/ && $2 != "branch" { print $3 }' $CTRL_FILE)
 
 for name in $trees; do
        [ -n "$start_from" ] && {