blob: f3a566269314ad52204365da7fd51ed84b0616e0 [file] [log] [blame]
Sapan Bhatia01ddea62017-02-10 11:28:48 -08001#!/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
5if [ -z "$1" ] || [ ! -e "$1" ]; then
6 echo "Usages: $0 <repo_diff_file>";
7 exit 0;
8fi
9
10rm -fr _tmp_splits*
11cat $1 | csplit -qf '' -b "_tmp_splits.%d.diff" - '/^project.*\/$/' '{*}'
12
13working_dir=`pwd`
14
15for proj_diff in `ls _tmp_splits.*.diff`
16do
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
25done