Repo diff 文件自动patch
2016-03-16(三) by chenjia.merepo diff 导出
REPO 是Android Source 的同步工具,使用repo diff
可以查看修改过的文件,那么使用repo diff > xxx.diff
就可以将内容导出成为文件
像普通的diff文件一样patch
使用google group一个人的代码:https://groups.google.com/forum/#!topic/repo-discuss/43juvD1qGIQ
## Script to patch up diff reated by `repo diff`
if [ -z "$1" ] || [ ! -e "$1" ]; then
echo "Usages: $0 <repo_diff_file>";
exit 0;
fi
rm -fr _tmp_splits*
cat $1 | csplit -qf '' -b "_tmp_splits.%d.diff" - '/^project.*\/$/' '{*}'
working_dir=`pwd`
for proj_diff in `ls _tmp_splits.*.diff`
do
chg_dir=`cat $proj_diff | grep '^project.*\/$' | cut -d " " -f 2`
echo "FILE: $proj_diff $chg_dir"
if [ -e $chg_dir ]; then
( cd $chg_dir; \
cat $working_dir/$proj_diff | grep -v '^project.*\/$' | patch -Np1;);
else
echo "$0: Project directory $chg_dir don't exists.";
fi
done
将该文件保存为sh并且加上执行权限,就可以使用./xxx.sh xxx.diff
打补丁了。。注意文件位置
以上