forked from tytso/ext4
/
extract_patch.sh
executable file
·62 lines (48 loc) · 1.81 KB
/
extract_patch.sh
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
#!/bin/sh
PATCH=ext4_snapshot_$1.patch
RPATCH=ext4_snapshot_$1-R.patch
CHECKPATCH=./scripts/checkpatch.pl
echo
echo extracting patch $PATCH...
echo
#git checkout $RBRANCH~$2 fs/ext4 || exit 1
# apply reverse patch on reverse work dir
patch -R -p3 -d fs/ext4.rev < .git/patches/$RBRANCH/$RPATCH || exit 1
# strip fake ifdefs and copy to forward work dir
for f in $( ls fs/ext4.rev ) ; do
./strip_ifdefs fs/ext4.rev/$f fs/ext4/$f snapshot y 2>/dev/null || exit 1
done
#git checkout $BRANCH || exit 1
# 'core' patch series doesn't include added snapshot C files
# include snapshot.h and snapshot_debug.h only in first 2 core patches
if [ _$3 = _core ] ; then
rm -f fs/ext4/snapshot*.c
[ $2 -le 2 ] || git checkout fs/ext4/snapshot*.h
fi
#guilt-push
for f in $( ls fs/ext4/* ) ; do
# file=${f%%.tmp}
# mv -f $f $file|| exit 1
git add $f || exit 1
done
if [ ! -f .git/patches/$RBRANCH/$RPATCH~ ]; then
echo 'reverse patch $RPATCH~ does not exist'
fi
cat .git/patches/$RBRANCH/$RPATCH~ > .git/patches/$QBRANCH/$PATCH~
#Add Signed-off-by lines.
echo '' >> .git/patches/$QBRANCH/$PATCH~ || exit 1
echo 'Signed-off-by: Amir Goldstein <amir73il@users.sf.net>' >> .git/patches/$QBRANCH/$PATCH~ || exit 1
echo 'Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>' >> .git/patches/$QBRANCH/$PATCH~ || exit 1
cat .git/patches/$QBRANCH/$PATCH~ > .git/patches/$QBRANCH/$PATCH
echo '' >> .git/patches/$QBRANCH/$PATCH || exit 1
git diff --cached >> .git/patches/$QBRANCH/$PATCH || exit 1
cat .git/patches/$QBRANCH/$PATCH~
git diff --cached --stat
#guilt-refresh
git commit -a --author='Amir Goldstein <amir73il@users.sf.net>' -F .git/patches/$QBRANCH/$PATCH~ || exit 0
echo $PATCH >> .git/patches/$QBRANCH/series
echo checking patch $PATCH...
$CHECKPATCH .git/patches/$QBRANCH/$PATCH >> ext4_snapshot_patches_check
echo
echo patch $PATCH applied.
echo