#!/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
shift
fi
-get_field()
-{
- awk -F '\t' '/^[^#]/ && $3 == "'"$1"'" { print $'"$2"'; }' "$CTRL_FILE"
-}
-
fetch_git()
{
git fetch "$1"
trees="$*"
if ! [ "$trees" ]; then
- trees=$(awk -F '\t' '/^[^#]/ && $2 != "branch" { print $3 }' "$CTRL_FILE")
+ trees=$(get_branches)
fi
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
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")