When someone emails a patch I like to view the context of the change, hence this view_full.sh script. The script assumes that your kernel source is in ~/progs/kernel/devel/. In mutt hit the '|' key and type ~/path/to/view_full.sh
After you exit vim it does patch -p1 -R to clean up.
#!/bin/bash -e
PATCH=$(mktemp)
tee $PATCH > /dev/null
files=$(grep ^+++ $PATCH | cut -f 1 | cut -b 5-)
cd ~/progs/kernel/devel/
if ! cat $PATCH | patch -p1 ; then
cat $PATCH | patch -R -p1
exit 1 # won't actually reach here because it's invoked with bash -e
# and the patch -R will fail.
fi
for file in $files ; do
line=$(grep -A1 "$file" $PATCH | tail -n 1 | cut -b 5- | cut -d ',' -f 1)
file=${file#*/}
vim $file +${line}
done
cat $PATCH | patch -p1 -R
rm $PATCH
One thing that is a bit annoying is that if you are in vim and type:
:! kchecker %
The line endings are messed up. The fix is to type:
:! kchecker % | less
No comments:
Post a Comment