-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathfrom-kernel.sh
More file actions
executable file
·70 lines (50 loc) · 1.57 KB
/
from-kernel.sh
File metadata and controls
executable file
·70 lines (50 loc) · 1.57 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -e
krepo="$1"
urepo=$(git rev-parse --show-toplevel)
patches=$(mktemp -d)
commit="$2"
if [ ! -d "$krepo" ]; then
echo "expected the kernel directory as \$1, but got \"$krepo\" which either doesn't exist or is not a directory"
exit 1
fi
pushd "$krepo" > /dev/null
if ! git cat-file -e "$commit^{commit}"; then
echo "commit $commit does not seem to exist."
exit 1
fi
echo "Copying all commits in \"$krepo\" into \"$urepo\" from commit $commit onwards:"
git log --oneline "$commit..HEAD"
read -p "Does this look good to you? [Y/n] " ans
case "$ans" in
Y)
;;
y)
;;
*)
exit 1
;;
esac
popd > /dev/null # $krepo
krepo=$(realpath "$krepo")
urepo=$(realpath "$urepo")
patches=$(realpath "$patches")
pushd "$krepo" > /dev/null
git format-patch --quiet --output-directory "$patches" "$commit"
pushd "$patches" > /dev/null
sed -i 's/^\(Subject: \[PATCH .*\] \)rust: pin-init: /\1/' *
popd > /dev/null # $patches
popd > /dev/null # $krepo
pushd "$urepo" > /dev/null
head=$(git rev-parse HEAD)
git am \
--signoff \
--reject \
--interactive \
-p3 \
--empty=drop \
$patches/*
# need the `--exec 'true'` in order for the `--no-keep-empty` option to actually do stuff
git rebase --no-keep-empty --quiet --exec 'true' "$head"
popd > /dev/null # $urepo
rm $patches/*