#!/bin/sh patch_name_from_fname() { echo $1 | cut -d- -f2 } apply_patch() { branch="$1" echo "" git checkout -b $branch cd .. > /dev/null patch -p1 < patches/$1 || exit 1 # git apply --reject patches/$1 || exit 1 git add *.c *.h *.mk *.1 cd - > /dev/null git commit -m "Applied $1" return 0 } git switch "patches" || exit git reset --hard "patches" -- || exit git clean -fd "../" # branches for individually applied patches branches=$(git for-each-ref --format='%(refname:short)' refs/heads/ | grep diff) for branch in $branches; do git branch -D $branch || exit done # branch for merged patches git branch -D patched git checkout -b "patched" for patchfile in *.diff; do apply_patch "$patchfile" || (git switch "patches" && exit) git switch -q "patched" done echo "Merge patch branches manually now"