Sapan Bhatia | 01ddea6 | 2017-02-10 11:28:48 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | ## Script to patch up diff reated by `repo diff` |
| 3 | |
| 4 | # from https://groups.google.com/d/msg/repo-discuss/43juvD1qGIQ/7maptZVcEjsJ |
| 5 | if [ -z "$1" ] || [ ! -e "$1" ]; then |
| 6 | echo "Usages: $0 <repo_diff_file>"; |
| 7 | exit 0; |
| 8 | fi |
| 9 | |
| 10 | rm -fr _tmp_splits* |
| 11 | cat $1 | csplit -qf '' -b "_tmp_splits.%d.diff" - '/^project.*\/$/' '{*}' |
| 12 | |
| 13 | working_dir=`pwd` |
| 14 | |
| 15 | for proj_diff in `ls _tmp_splits.*.diff` |
| 16 | do |
| 17 | chg_dir=`cat $proj_diff | grep '^project.*\/$' | cut -d " " -f 2` |
| 18 | echo "FILE: $proj_diff $chg_dir" |
| 19 | if [ -e $chg_dir ]; then |
| 20 | ( cd $chg_dir; \ |
| 21 | cat $working_dir/$proj_diff | grep -v '^project.*\/$' | patch -Np1;); |
| 22 | else |
| 23 | echo "$0: Project directory $chg_dir don't exists."; |
| 24 | fi |
| 25 | done |