#!/bin/bash
-[ "$1" = "-s" ] && {
+tools_dir=$(dirname "$0")
+. "$tools_dir/common.sh" ''
+
+if [ "$1" = '-n' ]; then
+ shift
+ 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
+
+if [ "$1" = '-s' ]; then
shift
start_from="$1"
- [ -z "$start_from" ] && {
- echo "-s requires a start tree" 1>&2
+ if [ -z "$start_from" ]; then
+ printf '-s requires a start tree\n' 1>&2
exit 1
- }
+ fi
shift
-}
-
-. "$(dirname $0)/common.sh" ""
-
-get_field()
-{
- grep -v '^#' $CTRL_FILE |
- awk -F '\t' '$3 == "'$1'" { print $'$2'; }'
-}
+fi
+# shellcheck disable=SC2317
fetch_git()
{
- git fetch "$1"
-}
-
-fetch_mmotm()
-{
- (
- cd ../mmotm || {
- echo "Cannot chdir to ../mmotm" 1>&2
- return
- }
- rsync -az --partial --exclude .git\* --exclude broken-out.tar.gz --delete ozlabs.org::akpm/mmotm/. . || {
- git reset --hard
- echo "Fetcing mmotm failed" 1>&2
- return
- }
- git add -A .
- [ "$(git status --porcelain)" ] &&
- git commit -m "$(head -n 1 .DATE)"
- )
-}
-
-fetch_quilt()
-{
- (
- url=$(get_field "$1" 4)
- url=${url%/} # strip trailing / if necessary
+ local name="$1" branch="$2" old_sha="$3" new_sha
- cd ../quilt || {
- echo "Cannot chdir to ../quilt" 1>&2
- return
- }
- [ -d "$1" ] || mkdir "$1" || {
- echo "Cannot create quilt directory for $1" 1>&2
- return
- }
- cd "$1" || {
- echo "Cannot chdir to quilt directory for $1" 1>&2
- return
- }
- wget -N -nv --no-cache "$url/series" || {
- echo "Wget of $1 series file failed" 1>&2
- cd ..
- rm -rf "$1"
- git checkout "$1"
- return
- }
- find * -type f | grep -v '^series$' | sort >.series.old
- if grep -q NEXT_PATCHES series; then
- sed -n '/NEXT_PATCHES_START/,/NEXT_PATCHES_END/p' series
- else
- cat series
- fi |
- sed -e 's/[ \t]*#.*$//' -e '/^[ \t]*$/d' |
- sort >.series.next
- [ -s .series.next ] && {
- wget -N -nv --no-cache -B "$url/" -i .series.next || {
- echo "Wget of series '$1' failed" 1>&2
- cd ..
- rm -rf "$1"
- git checkout "$1"
- return
- }
- }
- comm -23 .series.old .series.next | xargs -r rm -f
- rm -f .series.old .series.next
- setfattr -x user.xdg.origin.url * >/dev/null 2>&1
- )
+ if ! new_sha=$(git ls-remote "$name" "refs/heads/$branch") ||
+ [ -z "$new_sha" ]; then
+ printf '%s: Could not fetch %s branch %s\n' 'fetch_git' "$name" "$branch" >&2
+ printf '%s\n' "$old_sha"
+ return
+ fi
+ new_sha="${new_sha%%"${_TAB}"*}"
+ if [ "$new_sha" = "$old_sha" ]; then
+ printf '%s\n' "$old_sha"
+ return
+ fi
+ if git fetch "$name"; then
+ git rev-parse --verify "$name/$branch"
+ else
+ printf '%s\n' "$old_sha"
+ fi
}
-trees="$@"
-[ "$trees" ] ||
- trees=$(grep -v '^#' $CTRL_FILE | awk -F '\t' '{ print $3 }')
+trees="$*"
+if ! [ "$trees" ]; then
+ trees=$(get_branches)
+fi
for name in $trees; do
- [ -n "$start_from" ] && {
+ if [ -n "$start_from" ]; then
if [ "$name" = "$start_from" ]; then
- start_from=""
+ start_from=''
else
continue
fi
- }
+ fi
- type=$(get_field "$name" 2)
+ type=$(get_type "$name")
+ if ! [ "$type" ]; then
+ printf '%s: unknown tree\n' "$name" 1>&2
+ continue
+ fi
- echo $name: $type
- [ $(type -t "fetch_$type") = "function" ] &&
- fetch_$type "$name"
-done
+ if [ "$(get_url "$name")" = 'linux-next' ]; then
+ continue
+ fi
-cd ../quilt
-git add -A .
-[ "$(git status --porcelain)" ] &&
- git commit -v -a -m "$(date '+%F-%H:%M')" -e
+ printf '%s: %s\n' "$name" "$type"
+ fun="fetch_$type"
+ tfun=$(type -t "$fun")
+ if [ "$tfun" = 'function' ]; then
+ branch=$(get_remote_branch "$name")
+ old_sha=$(git rev-parse --quiet --verify "$name/$branch")
+ new_sha=$("$fun" "$name" "$branch" "$old_sha")
+ check_dups "$name" origin/master "$new_sha"
+ if ! [ "$new_sha" = "$old_sha" ]; then
+ "$tools_dir"/check_commits ^origin/master "$old_sha..$new_sha"
+ fi
+ fi
+done
exit 0