blob: 0f7837b147a88aa79f21a7ce877e37bdab02c29b [file] [log] [blame]
#!/bin/bash -eu
. "$(dirname "$0")"/lsq-defs
set -o pipefail
export GIT_DIR="$UPSTREAM_GIT/.git"
# Optional end-point for import
if [ -n "${1:-}" ]; then
endpoint="$1"
if git rev-list origin/master.."$endpoint" | grep -q .; then
echo >&2 "$endpoint is not an ancestor of origin/master"
fi
else
endpoint=origin/master
fi
# Iterate over all patches since last import that were cc'd to stable
# or have a Fixes: tag
git rev-list --no-merges -i -E --grep '^(Cc:\s*(.*<)?stable@(vger\.)?kernel\.org\b|Fixes:)' \
"$(cat "$STABLE_QUEUES/upstream-head")".."$endpoint" | \
tac | \
while read commit; do
read patch rest < <(git format-patch-for-backport --no-signature --subject-prefix='' $commit -1)
if [ -n "$rest" ]; then
# Patch is commented as being for some range of stable versions.
# Don't try to parse the comment.
echo "Commit $commit has comment: $rest"
fi
fixes="$(sed -n 's/^Fixes: //p' "$patch" || true)"
if [ -n "$fixes" ]; then
echo "Commit $commit fixes: $fixes"
fi
signoff-patch "$patch"
for version in $STABLE_BASE_VERSIONS; do
queue="$(get_queue $version)"
if [ -n "$rest" -o -n "$fixes" ]; then
while true; do
read -p "Do we want this in $version? " </dev/tty
if [ "${REPLY#[ny]}" != "$REPLY" ]; then
break
fi
done
if [ "${REPLY#n}" != "$REPLY" ]; then
echo "Not adding $commit to $version"
continue
fi
fi
# Can't use quilt import here because we're adding to the end
cp "$patch" $queue/
patch2="$(rename-patch "$queue/$patch")"
echo "Adding $commit as $patch2"
echo "$(basename "$patch2")" >> $queue/series
done
rm "$patch"
done
# Update last import
git rev-list "$endpoint" -1 >"$STABLE_QUEUES/upstream-head"