-
Notifications
You must be signed in to change notification settings - Fork 31
/
propagatediff.sh
executable file
·32 lines (28 loc) · 976 Bytes
/
propagatediff.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
#!/bin/bash
set -e
set -o pipefail
. chapters.sh
startidx="${3}"
: ${startidx:=0}
for c in $(seq $startidx $(( ${#chapters[@]} - 2)) ) ; do
n=$(( $c + 1 ))
curr=${chapters[$c]}
next=${chapters[$n]}
echo "$curr -> $next"
find ${storydir}/${curr} -type f -name '*.orig' -delete
git add -N ${storydir}/${curr}
git diff ${storydir}/${curr} | ./filterdiff.sh | patch -d ${storydir}/${next} -p2 --merge=diff3 -V never || \
{
sed -i -e 's#<<<<$#<<<< MINE#; s#>>>>$#>>>> OTHER#; s#||||$#|||| ANCESTOR#' \
$(ag -l '<<<<|>>>>' ${storydir}/${next})
echo
echo "Resolve conflicts in ${storydir}/${next}"
(echo "#!/bin/bash"; echo "$0 $storydir $diffdir $n") > continue.sh
chmod 0755 continue.sh
echo "Continue with $0 $storydir $diffdir $n (I made continue.sh for you)"
exit 1
}
git add -N ${storydir}/${next}
done
[ -f continue.sh ] && rm continue.sh
echo "DONE"