summaryrefslogtreecommitdiff
path: root/patches/dwmpatch
blob: df2778196f2be3e0e5bcecfce929d518c625571f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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

git checkout -b "patched" || git switch "patched"
git status
for patchfile in *.diff; do
	apply_patch "$patchfile" || (git switch "patches" && exit)
	git switch -q "patched"
done

echo "Merge patch branches manually now"