Files
unkernel/kernel/tools/export-patches.sh
Pooya Parsa 25e0add13f kernel: fold the patch series and export it without churn
Fold the 56 kernel patches into 32: one arch patch (which now includes
the riscv ISA patch, parking, atomics, SMP, blocking waits, unfair
spinlocks, the arm64 user ABI, pc sampling, ptrace, single-step and core
dumps), each driver with its SMP part, the generic changes one per piece
(the cond_resched() poll split out of the arch patch), and kw_defconfig
last. The messages describe the code as it is; every patch that was
kernel-wasm@localhost's is Pooya Parsa's. The tree is unchanged.

kernel/build.sh patches (kernel/tools/export-patches.sh) exports the
series without what changed in every later patch on each edit: no
numbers in the file names (the order is the new series file, which
build.sh applies), a zero commit hash, no git version signature and no
index lines, with the diff options fixed.
2026-11-28 18:55:49 +00:00

66 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
#
# Export a branch as a patch series that changes only where its commits do:
#
# kernel/tools/export-patches.sh [--check] TREE BASE..BRANCH OUTDIR
#
# OUTDIR gets one <subject>.patch per commit (no number, so adding or
# dropping a patch renames nothing) and `series`, the order to apply them
# in. The patches carry no commit hash (--zero-commit), no git version
# signature and no `index` lines (blob hashes, which change whenever an
# earlier patch touches the same file); `git am` needs none of them.
# Patches no longer in the series are removed. With --check nothing is
# written: the exit status is 1 if OUTDIR differs from the export.
set -euo pipefail
check=0
if [ "${1:-}" = --check ]; then check=1; shift; fi
if [ $# -ne 3 ]; then
echo "usage: $0 [--check] TREE BASE..BRANCH OUTDIR" >&2
exit 2
fi
tree=$1 range=$2 out=$3
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
mkdir "$tmp/raw" "$tmp/out"
# Every option that would otherwise come from the user's git config.
git -C "$tree" format-patch -q -o "$tmp/raw" \
--no-numbered --zero-commit --no-signature --no-cover-letter --no-thread \
--default-prefix --no-renames --diff-algorithm=myers "$range"
: >"$tmp/out/series"
for f in "$tmp/raw"/*.patch; do
[ -e "$f" ] || break
name=$(basename "$f")
name=${name#[0-9][0-9][0-9][0-9]-}
if [ -e "$tmp/out/$name" ]; then
echo "two patches would be named $name: reword one subject" >&2
exit 1
fi
# A diff body line starts with ' ', '+', '-' or '\', so a line that
# starts with "index <hex>.." is always a header.
sed -E '/^index [0-9a-f]+\.\.[0-9a-f]+( [0-7]+)?$/d' "$f" >"$tmp/out/$name"
echo "$name" >>"$tmp/out/series"
done
if [ "$check" = 1 ]; then
mkdir -p "$tmp/cur"
if [ -d "$out" ]; then
cp "$out"/series "$out"/*.patch "$tmp/cur/" 2>/dev/null || true
fi
if ! diff -r -q "$tmp/cur" "$tmp/out" >&2; then
echo "$out does not match $range: run $0 $tree $range $out" >&2
exit 1
fi
exit 0
fi
mkdir -p "$out"
rm -f "$out"/*.patch "$out"/series
cp "$tmp/out"/* "$out/"
echo "$(wc -l <"$out/series") patches in $out"